0
我與一個C#WCF數據服務一個奇怪的問題,和iOS的客戶端(使用的OData SDK)。WCF數據服務 - 的iOS SDK的OData問題
這是我WCF數據服務的一個簡化版本:
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.
[WebGet(ResponseFormat = WebMessageFormat.Json)]
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();
}
}
的服務,目前主辦過現場,所以我可以證實,我可以瀏覽到它,並通過實體集合等導航
我寫了下面的代碼在我的iOS應用程序只是測試到服務的連接:
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");
}
但是連接後時I g簡單地掛起等200個狀態碼(只有5個在數據庫中的項目,所以我知道這是不是與數據的大小問題)。
但是如果我更改代碼從羅斯文的OData服務閱讀,(並添加文件通過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];
NSLog(@"Got Results");
if([resultArray count] > 0)
{
NSLog(@"Got Results");
}
我得到的結果如預期。 我很茫然,什麼我的拼圖中缺失的部分是,所以任何指針將是很有益的。
問候
什麼神的名字是WebGet在那裏做什麼? – jere 2012-08-14 05:55:52