我正在尝试将XML数据发送到Web服务。但我没有得到任何服务的回应。当我试图通过SOAPUI发送XML时...我得到错误为“Incoming parameter failiure”..任何人都可以检查我的代码并指出我做错了什么..
- (void)viewDidLoad
{
NSString *Message = [NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<SOAP-ENV:Envelope \n"
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \n"
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n"
"xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" \n"
"SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" \n"
"xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"> \n"
"<SOAP-ENV:Body> \n"
"<XMLGetReportParameters xmlns=\"http://PlusDiagnostics.Schemas.GetReportParameters\"><UserName xmlns="">USERNAME</UserName><Password xmlns="">PASSWORD</Password><List xmlns="">All</List></XMLGetReportParameters>"
"</SOAP-ENV:Body> \n"
"</SOAP-ENV:Envelope>" ];
NSURL *url = [NSURL URLWithString:@"https://pathflexstage.plusdx.com/MobileReporting/GetPathologyReports.svc"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [Message length]];
NSLog(@"message length is %d",[Message length]);
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest addValue: @"http://tempuri.org/IGetPathologyReports/GetReports" forHTTPHeaderField:@"soapAction"];
[theRequest setHTTPBody: [Message dataUsingEncoding:NSUTF8StringEncoding]];
NSString *returnString = [[NSString alloc] initWithData:[NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil] encoding:NSUTF8StringEncoding];
// NSLog("return");
NSLog(@"%@",returnString);
[super viewDidLoad];
}
答案 0 :(得分:1)
您将从服务器接收回复内容,可能是错误。
声明以下内容;
NSURLResponse *response = nil;
NSError *error = nil;
...然后提出你的要求;
NSString *returnString = [[NSString alloc] initWithData:[NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error] encoding:NSUTF8StringEncoding];
...如果您随后检查了响应和错误,您应该能够找到问题的路线。