我正在使用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