2010-06-28 66 views
3

我想从我的Iphone应用程序调用基于会话的web服务。但是,由于Iphone App不允许存储存储会话信息所必需的cookie,因此我无法使其工作。基于会话的Web服务

我已阅读以下文章,似乎有办法处理基于会话的Web服务,但是,我无法找到它应该如何工作。

http://msdn.microsoft.com/en-us/library/aa480509.aspx

+1

你是什么意思,它不允许有cookie?你有坚持,所以你可以自己管理它。 – 2010-06-28 16:47:45

回答

4

iPhone确实支持cookies。你可以看到在http://developer.apple.com/iphone/library/documentation/cocoa/reference/foundation/Classes/NSHTTPCookieStorage_Class/Reference/Reference.html

的支持如果你只是在做简单的HTTP请求,我强烈建议使用源代码ASIHTTPRequest http://allseeing-i.com/ASIHTTPRequest/

他们使它很容易做数据简单的请求,甚至处理异步要求。我一直在我的应用程序中使用代码。

NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"]; 
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; 
[request startSynchronous]; 
NSError *error = [request error]; 
if (!error) { 
    NSString *response = [request responseString]; 
}