WCF Data Service - iOS oData SDK Issues

Mar 21, 2011 at 11:49 PM
Edited Mar 21, 2011 at 11:50 PM

I  have a strange problem relating to a C# WCF Data Service, and a iOS client (using the oData SDK).

Here is a simplified version of my WCF Data Service:

 

using System;
using System.Data.Services;
using System.Data.Services.Common;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Web;
using FootballFeedsModel;
[ServiceBehavior]
public class FootballFeeds : DataService<FootballFeedsEntities > {
   // This method is called only once to initialize service-wide policies.
   public static void InitializeService(DataServiceConfiguration config)
   {
       config.SetEntitySetAccessRule("*", EntitySetRights.All);
       config.SetServiceOperationAccessRule("TeamsList", ServiceOperationRights.All);
       config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
   }
   [WebGet (ResponseFormat = WebMessageFormat.Json)]
   public IQueryable<Team> TeamsList(){
       return new FootballFeedsEntities().Teams.AsQueryable();
   }
}

 

The services is currently hosted live, so I can confirm that I can browse to it, and navigate through the Entity collection etc.

 

I wrote the following code in my iOS application simply to test the connection to the service:

 

FootballFeedsEntities *proxy = [[FootballFeedsEntities alloc] initWithUri:@"http://testwebserver.com/Services/FootballFeeds.svc" credential:nil];
DataServiceQuery *query = [proxy teams];
QueryOperationResponse *response = [query execute];
resultArray =[[response getResult] retain];
if([resultArray count] > 0 )
{
	NSLog(@"Got Results");
}

 

However the connection simply hangs after I get a 200 status code (there are only 5 items in the database, so I know it is not an issue with the size of the data).

 

However if I change the code to read from the oData Northwind service, (and add files for this service produced by odatagen)

 

NorthwindEntities *proxy = [[NorthwindEntities alloc] initWithUri:@"http://services.odata.org/Northwind/Northwind.svc" credential:nil];
DataServiceQuery *query = [proxy teams];
QueryOperationResponse *response = [query execute];
resultArray =[[response getResult] retain];
if([resultArray count] > 0 )
{
	NSLog(@"Got Results");
}

 

I get results as expected. I am at a loss as to what the missing piece of my jigsaw is, so any pointers would be really helpful.

 

Regards

Mar 22, 2011 at 2:40 PM
Edited Mar 22, 2011 at 2:41 PM

try to use config.SetServiceOperationAccessRule("*", ServiceOperationRights.All); instead config.SetServiceOperationAccessRule("TeamsList", ServiceOperationRights.All);

or

use config.UseVerboseErrors=true, to get exact error.

Browse http://testwebserver.com/Services/FootballFeeds.svc/teams/ on browser.

Hope this will help you.

Aug 1, 2011 at 11:36 PM

Mick, did you get this working?  Also, from the Objective C side, what kind of List/Array/etc is your "resultArray" object?  How did you instantiate that?  I have my proxy and everything.  I'm just not quite sure what I receive on the Obj. C side.

 

thanks

 

Mark