I've got an interesting situation. I have two applications calling a function on a Microsoft WCF OData service:
- Android using OData4J library (v0.7)
- iOS using OData4ObjC library (Elizabeth Duncan fork for iOS 6.1)
The OData service is written using Microsoft WCF Data Service v5.6. I'm using a [WebGetAttribute()]
attribute on a method in my service class:
namespace MyServices
{
public class MyService : DataService<MyEntities>
{
public static void InitializeService(DataServiceConfiguration config)
{
config.UseVerboseErrors = true;
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
config.SetServiceOperationAccessRule("MyServiceCall", ServiceOperationRights.ReadSingle);
}
[WebGet()]
public IQueryable<MyComplexType> MyServiceCall()
{
return AListOfMyComplexTypes();
}
}
}
When the Android app makes an OData function call, the WCF data service responds with a v1 collection of complex types. When the iOS library makes a function call to the WCF data service it is expecting the collection to be returned using v3.
My questions are:
- Is it possible to get the OData4ObjC library to communicate using OData v1 protocols?
- Is it possible to get the WCF Data Service to respond using OData v3 protocols?
- What do I need to do to get item 1 and/or item 2 to work?
Here's what I mean by an OData v1 response:
<MyServiceCall
xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<element m:type="MyService">
<Id m:type="Edm.Int16">1</Id>
<Name>Bariatric</Name>
<IsEnabled m:type="Edm.Boolean">true</IsEnabled>
</element>
<element m:type="MyService">
<Id m:type="Edm.Int16">2</Id>
<Name>General</Name>
<IsEnabled m:type="Edm.Boolean">true</IsEnabled>
</element>
</MyServiceCall>
And this is what I mean by an OData v3 response:
<?xml version="1.0" encoding="utf-8"?>
<feed xml:base="http://services.odata.org/V3/(S(ii5qwgb20wk0ptgfvvtlpwoy))/OData/OData.svc/"
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">
<id>
http://services.odata.org/V3/(S(ii5qwgb20wk0ptgfvvtlpwoy))/OData/OData.svc/GetProductsByRating</id>
<title type="text">GetProductsByRating</title>
<updated>2013-10-17T21:56:42Z</updated>
<link rel="self" title="GetProductsByRating" href="GetProductsByRating" />
<entry>
<id>http://services.odata.org/V3/(S(ii5qwgb20wk0ptgfvvtlpwoy))/OData/OData.svc/Products(1)/id>
<category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="Product" href="Products(1)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Category" type="application/atom+xml;type=entry" title="Category" href="Products(1)/Category" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier" type="application/atom+xml;type=entry" title="Supplier" href="Products(1)/Supplier" />
<title type="text">Milk</title>
<summary type="text">Low fat milk</summary>
<updated>2013-10-17T21:56:42Z</updated>
<author>
<name />
</author>
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Category" type="application/xml" title="Category" href="Products(1)/$links/Category" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Supplier" type="application/xml" title="Supplier" href="Products(1)/$links/Supplier" />
<m:action metadata="http://services.odata.org/V3/(S(ii5qwgb20wk0ptgfvvtlpwoy))/OData/OData.svc/$metadata#DemoService.Discount" title="Discount" target="http://services.odata.org/V3/(S(ii5qwgb20wk0ptgfvvtlpwoy))/OData/OData.svc/Products(1)/Discount" />
<content type="application/xml">
<m:properties>
<d:ID m:type="Edm.Int32">1</d:ID>
<d:ReleaseDate m:type="Edm.DateTime">1995-10-01T00:00:00</d:ReleaseDate>
<d:DiscontinuedDate m:null="true" />
<d:Rating m:type="Edm.Int32">3</d:Rating>
<d:Price m:type="Edm.Decimal">3.5</d:Price>
</m:properties>
</content>
</entry>
</feed>