我正在使用ASIHTTPRequest類來與Web服務進行通信並獲得響應。這是我發送一個請求到服務器iPhone和ASIHTTPRequest - 無法啓動HTTP連接
NSString *str = [NSString stringWithFormat:@"%@verifyLogin.json", serverUrl];
NSURL *url = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request addRequestHeader:@"Content-Type" value:@"text/x-gwt-rpc; charset=utf-8"];
NSDictionary* data = [NSDictionary dictionaryWithObjectsAndKeys:emailId, @"username", pwd, @"password", nil];
[request appendPostData: [[data JSONFragment] dataUsingEncoding: NSUTF8StringEncoding]];
[request setRequestMethod:@"POST"];
[request setDelegate:self];
[request setDidFinishSelector: @selector(gotLoginResponse:)];
[request setDidFailSelector: @selector(loginRequestFailed:)];
[networkQueue addOperation: request];
[networkQueue go];
控制立即轉到錯誤例程和錯誤描述和域
無法啓動HTTP連接和ASIHTTPRequestErrorDomain
我可以通過桌面工具獲取相同的請求來檢查HTTP請求,所以我知道這些設置都是正確的。
有人可以告訴我在發送請求時我在這裏失蹤嗎?
謝謝。
它在第一行中顯示「%verifyLogin.json」。不應該那樣; 「%@verifyLogin.json」? – Jake 2009-10-20 13:51:57
我有同樣的問題,運氣好嗎?! – Sasho 2013-08-22 10:40:47