GithubHelp home page GithubHelp logo

OData v2 support about odata-client HOT 8 OPEN

davidmoten avatar davidmoten commented on June 15, 2024
OData v2 support

from odata-client.

Comments (8)

kriegfrj avatar kriegfrj commented on June 15, 2024 1

Here is the definitive reference for the differences between OData 2 and 4: http://docs.oasis-open.org/odata/new-in-odata/v4.0/cn01/new-in-odata-v4.0-cn01.html
There are also a couple of summaries of the difference between OData v2 and v4:

I've gone with the munging approach as a bit of an exploration. For my particular service, these are the sticking points that I have found so far:

  1. The xml namespace schema declarations have to be updated to the OData v4 ones (http://schemas.microsoft.com/ado/2008/09/edm -> http://docs.oasis-open.org/odata/ns/edm, http://schemas.microsoft.com/ado/2007/06/edmx -> http://docs.oasis-open.org/odata/ns/edmx).
  2. <NavigationProperty> syntax is different. v2 does not have a Type property (from what I can tell, type is inferred by referring to the type of the values that are linked to), v4 requires it to be set explicitly on the property declaration itself. To get my schema to compile, I had to comment out the <NavigationProperty> elements for now.
  3. Some of the primitive data types have changed, in particular Edm.DateTime has been deprecated. It seems that the client generator at the moment doesn't handle the deprecated type and skips it. Had to change these to make it work.

It would be nice if this was more seamless, but I now have a schema that compiles and is hitting remote servers. Ready for the next hurdle! 😄 Thanks for your help @davidmoten .

from odata-client.

davidmoten avatar davidmoten commented on June 15, 2024

I don't know. I'm not familiar with v2. I'll have a short look at what's changed. What product are you connecting to?

from odata-client.

davidmoten avatar davidmoten commented on June 15, 2024

Can you give me your v2 metadata to see what the differences are?

from odata-client.

kriegfrj avatar kriegfrj commented on June 15, 2024

Thanks for the response @davidmoten. Unfortunately, I'm not sure that I can give you the metadata for my specific service due to its licensing, but I found another sample OData v2 service online here:

https://services.odata.org/V2/OData/OData.svc/$metadata

The main difference between it and mine seems to be the version of the schema XML namespace used for the <Schema> element (the sample service reports http://schemas.microsoft.com/ado/2007/05/edm and my service is using http://schemas.microsoft.com/ado/2008/09/edm). I'm not sure how much of a difference that makes. There are also some extra proprietary attributes on the <Property> elements of the 'EntityType' declarations.

from odata-client.

kriegfrj avatar kriegfrj commented on June 15, 2024

Upon investigation:

I was getting an NPE here:

when I was trying to run this on the v2 metadata. I had assumed that this was because it was v2. When I downloaded and tried out the odata-client project itself on my system, I was getting the same error when trying to build

This could be a bug or a misconfiguration error on my part (even if it's a misconfiguration error, I'd consider it a bug that the diagnostics aren't more useful). I'll continue to investigate.

from odata-client.

davidmoten avatar davidmoten commented on June 15, 2024

V2 does look very similar. You might be able to modify the metadata file to make it comply with V4 and then use the generated client.

The xml namespace will be important. You will want to modify the namespaces to look like this simple example in V4:

https://github.com/davidmoten/odata-client/blob/master/odata-client-test-unit/src/main/odata/metadata1.xml

The null pointer is probably because you are loading a file with a root element of a completely different namespace and the t in your code extract ends up being null because there is no match at all.

from odata-client.

kriegfrj avatar kriegfrj commented on June 15, 2024

Thanks for the response David. I've come to a similar conclusion. I'm having a bit of a play with it at the moment.

There were two causes of the NPE. One of them I reported in #145. The other is I think due to the reason that you specified.

I managed to track down XSD files for OData v2; I'll see if these can be incorporated. Otherwise, munging my xml to make it look like OData v4 might work.

from odata-client.

davidmoten avatar davidmoten commented on June 15, 2024

Nice work @kriegfrj !

from odata-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.