2010-06-28 65 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]; 
}