我在我的网站的服务器www.example.com/webservice/SampleService.asmx
上传了一个Web服务,我要连接到它的方法是GetAllUserInfo
,我使用下面的代码来使用这个Web服务但是发生了运行时错误,任何人都可以帮助我使用这个Web服务
NSString *soapMsg =[NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>" "<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/\">" "<soap:Body>" "<GetAllUserInfo xmlns=\"http://www.example.com/\">" "</GetAllUserInfo>" "</soap:Body>" "</soap:Envelope>"]; NSURL *url = [NSURL URLWithString:@"http://www.example.com/SampleService.asmx"]; NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]]; [req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [req addValue:@"http://www.example.com/GetAllUserInfo" forHTTPHeaderField:@"SOAPAction"]; [req addValue:msgLength forHTTPHeaderField:@"Content-Length"]; [req setHTTPMethod:@"POST"]; [req setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
答案 0 :(得分:1)
您可以使用以下命令获取完整的错误消息:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
NSLog(@"data: %.*s", [data length], [data bytes]);
}