读书人

使用ASIHTTPRequest时遇到的小疑点求

发布时间: 2012-12-14 10:33:07 作者: rapoo

使用ASIHTTPRequest时遇到的小问题,求达人解释


//返回ASIHTTPRequest对象
-(ASIHTTPRequest*)ServiceRequestUrl:(NSString*)strMethod SoapMessage:(NSString*)soapMsg{
//请求发送到的路径
NSURL * url = [NSURLURLWithString:@"http://192.168.123.132/eland/WebServices/WebService.asmx"];

//NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
ASIHTTPRequest *theRequest= [ASIHTTPRequestrequestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];

//以下对请求信息添加属性前四句是必有的,第五句是soap信息。
[theRequest addRequestHeader:@"Host" value:[url host]];
[theRequest addRequestHeader:@"Content-Type"value:@"text/xml; charset=utf-8"];
[theRequest addRequestHeader:@"Content-Length" value:msgLength];
[theRequest addRequestHeader:@"SOAPAction"value:[NSStringstringWithFormat:@"http://tempuri.org/%@", strMethod]];
[theRequest setRequestMethod:@"POST"];
//传soap信息
[theRequest appendPostData:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
//[theRequest setValidatesSecureCertificate:NO];
[theRequest setTimeOutSeconds:60.0];
[theRequest setDefaultResponseEncoding:NSUTF8StringEncoding];
return theRequest;
//return theRequest;
}

//在按钮点击下执行请求
-(IBAction)buttonServiceClick:(id)sender{
NSString *soapMsg=@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<soap:Body><GetCircular xmlns=\"http://tempuri.org/\" ><guid>07122d99-0978-46e4-aacb-3aed0ff99cb5</guid><pwd>123456</pwd><GetCircular></soap:Body></soap:Envelope>";

ASIHTTPRequest *request=[selfServiceRequestUrl:@"GetCircular"SoapMessage:soapMsg];
[request setDelegate:self];
[request startAsynchronous];//异步请求
}
//实现协议
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSString *responseString = [request responseString];
NSLog(@"%@",responseString);
}

- (void)requestFailed:(ASIHTTPRequest *)request
{
NSError *error = [request error];
NSLog(@"%@",[error description]);
}



===>点击按钮时,发生 怪异了,在控制台一直输出==》
错误的请求

求达人,我那里错了???
[解决办法]
没有人知道吗?
[解决办法]
我也在看ASIHTTPRequest类库 遇到不少问题

[解决办法]
貌似程序没有错,是不是服务端的问题
[解决办法]
我在去查询一下是什么问题
[解决办法]
引用:
貌似程序没有错,是不是服务端的问题


老弹出===》的要求
快无语了???
[解决办法]
可惜是内网的,没法帮你测试
[解决办法]
引用:
可惜是内网的,没法帮你测试



http://dl.vmall.com/c0mjeilzp3 这是我的源码,可以直接测???我是不知道怎么修改
[解决办法]
以解决,是soap参数先后顺序的错???

读书人网 >Iphone

热点推荐