0

The following code throws the following exception on SaveChanges():

System.Data.Services.Client.DataServiceRequestException was unhandled
  HResult=-2146233079
  Message=An error occurred while processing this request.
  Source=Microsoft.Data.Services.Client
  StackTrace:
       at System.Data.Services.Client.SaveResult.HandleResponse()
       at System.Data.Services.Client.BaseSaveResult.EndRequest()
       at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)
       at System.Data.Services.Client.DataServiceContext.SaveChanges()
       at AirportDataImporter.Program.Main(String[] args) in c:\Projects\Airport\Dev\AirportWeb\AirportDataImporter\Program.cs:line 23
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Data.Services.Client.DataServiceClientException
       HResult=-2146233079
       Message=Format Exception: Invalid 'Point' format!
    at Function.$data.GeographyBase.validateGeoJSON (/usr/lib/node_modules/jaydata/lib/TypeSystem/Types/Geography.js:75:29)
    at GeographyPoint.GeographyBase (/usr/lib/node_modules/jaydata/lib/TypeSystem/Types/Geography.js:6:25)
    at new GeographyPoint (/usr/lib/node_modules/jaydata/lib/TypeSystem/Types/Geography.js:94:29)
    at $data.oDataConverter.fromDb.$data.GeographyPoint (/usr/lib/node_modules/jaydata/lib/Types/StorageProviders/oData/oDataConverter.js:55:64)
    at Airport.$data.Entity.$data.Class.define.constructor (/usr/lib/node_modules/jaydata/lib/Types/Entity.js:189:41)
    at Airport.Entity (eval at <anonymous> (/usr/lib/node_modules/jaydata/lib/TypeSystem/TypeSystem.js:463:20))
    at new Airport (eval at <anonymous> (/usr/lib/node_modules/jaydata/lib/TypeSystem/TypeSystem.js:463:20))
    at EntitySetProcessor.$data.Class.define.invoke (/usr/lib/node_modules/jaydata/lib/JayService/OData/EntitySetProcessor.js:61:38)
    at JSObjectAdapter.$data.Class.define.processRequest (/usr/lib/node_modules/jaydata/lib/JayService/JSObjectAdapter.js:89:37)
    at JSObjectAdapter.$data.Class.define.handleRequest (/usr/lib/node_modules/jaydata/lib/JayService/JSObjectAdapter.js:165:26)
       StatusCode=500
       InnerException: 

It has something to do with the conversion of the C# GeographyPoint to its json/javascript equivalent. Can someone tell me what I need to do to make this work? Since there seems to be no JayStack data importers, I need to make this work in order to initialize my data:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Spatial;
using System.Text;
using System.Threading.Tasks;

namespace AirportDataImporter
{
    class Program
    {
        static void Main(string[] args)
        {
            var db = new AirportDB.mydatabaseService(new Uri("https://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase/"));

            var airport = new AirportDB.Airport();
            airport.Abbrev = "Foo";
            airport.Name = "Bar";

            airport.GeoLocation = GeographyPoint.Create(51.87796, -176.64603);
            db.AddToAirport(airport);

            db.SaveChanges();

        }
    }
}

Additionally, the Visual Studio generated service reference hard codes odata version 2 for which jaydata also throws a different exception. I hand edited the generated proxy file to v3 to fix this. This is not an ideal way to do this. Any pointers in that regard?

Fiddler captured network payload is:

    <?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
   <category term="mydatabase.Airport" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
   <id />
   <title />
   <updated>2013-06-16T12:16:11Z</updated>
   <author>
      <name />
   </author>
   <content type="application/xml">
      <m:properties>
         <d:Abbrev>Foo</d:Abbrev>
         <d:GeoLocation m:type="Edm.GeographyPoint">
            <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
               <gml:pos>51.87796 -176.64603</gml:pos>
            </gml:Point>
         </d:GeoLocation>
         <d:id m:null="true" />
         <d:Name>Bar</d:Name>
      </m:properties>
   </content>
</entry>

Thanks TJ

t316
  • 1,149
  • 1
  • 15
  • 28

1 Answers1

0

Catch the network traffic with fiddler or burp and paste the relevant part here.

Gabor Dolla
  • 2,680
  • 4
  • 14
  • 13
  • I edited the post to contain the fiddler captured POST payload. – t316 Jun 16 '13 at 12:24
  • we have a few example with geography over odata here: http://jaydata.org/examples/?tags=Geo if you take a look at any of then you can see how geo data is sent over odata, for example look at this query: https://dev-open.jaystack.net/06b63652-9ec1-4c42-82ad-ed6875efacfb/7b261639-c46e-4913-b14f-ea3d3f899fcb/api/mydatabase/POI – Gabor Dolla Jun 16 '13 at 13:45
  • As .net geo data is so different I think it'd be easier to upload your data from browser or a nodejs app. In my examples I uploaded from nodejs, it took me 5 mins, I can share it with you – Gabor Dolla Jun 16 '13 at 13:48