0

I am trying to do a proof of concept with the odata compliant cloud database feature of JayStorm. So far it's going great, but I have one big problem that fits in the category of odata service client proxy serialization category.

My odata service url is: https://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase/

I create a simple .Net console app and add a service reference to this service. It all looks fine at first, however there is an incompatibility between the server side data type for GeoLocation (json payload is: {"type":"Point","coordinates":[-71.56236648559569,42.451074707889646],"crs":{"properties":{"name":"EPSG:4326"}) and the client side type the add reference wizard chooses. It seems they are very different data types and just client side select queries or client side insert/updates don't work. For example the below code throws an exception on line 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 JumpSeatDataImporter.Program.Main(String[] args) in c:\Projects\JumpSeat\Dev\JumpSeatWeb\JumpSeatDataImporter\Program.cs:line 24
       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: 

Here is the code:

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 AirprotDB.mydatabaseService(new Uri("https://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase/"));

            //{"Name":"sfd","Abbrev":"sd","GeoLocation":{"type":"Point","coordinates":[-71.56236648559569,42.451074707889646],"crs":{"properties":{"name":"EPSG:4326"},"type":"name"}}}

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

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

            db.SaveChanges();

            //var foo = db.Airport.ToList();


        }
    }
}

What can I do to have the client side proxy use a fitting (custom declared?) class which will allow me to round trip data, including the GeoLocation property? Without this, I can't upload/update data from sql server and files to JayStorm...

You should be able to emulate my issue fully by adding a service to a console app and running the above provided code. Don't worry about messing up the data.

Thanks

t316
  • 1,149
  • 1
  • 15
  • 28

1 Answers1

0

The geo types are exposed only via JSON format right now (this might change in the mid-term) and .NET uses XML by default, which leaves three options:

  • make your .NET app to work in JSON format with Data Services Client 5.5.0 and Data Services Tools 5.3 (this generates a new proxy, which accepts the Format property on the context) - I wasn't able to achieve this in .NET, but I do hope you are better than me :)
  • you use a HTML5 page or node.js to import your POIs with JayData library
  • you post you csv file to a JayStorm service operation, which processes the file. You post to the service operation with HttpRequest
Robesz
  • 1,646
  • 11
  • 13
  • consider paging the upload and the inserts. Normally we use chunks with 200 records. – Robesz Jun 18 '13 at 08:48
  • Please view this comment: http://stackoverflow.com/questions/17059864/consume-odata-service-and-get-result-in-json/17060863?noredirect=1#comment24869327_17060863 – t316 Jun 18 '13 at 19:40
  • I updated the data services client and got a lot farther however now there seems to be a odata v3 compliance issue with the JayStorm service. You can read my progress in the comments section of this SO post and you can see the last comment y someone who seems to be knowledgeable in the matter: http://stackoverflow.com/questions/17059864/consume-odata-service-and-get-result-in-json/17060863?noredirect=1#comment24869327_17060863 – t316 Jun 18 '13 at 23:45