当我在soap webservice中点击此链接时,第1行的'soap:Envelope'开始标记的响应与'soapody'的结束标记不匹配。
http://74.54.137.138:3052/Service.asmx?op=GetFlightDetailforSQAR
2:10 PMrecevedstring ---> soaperverServer无法处理请求。 --->
第1行的'soap:Envelope'开始标记与'soapody'的结束标记不匹配。第1行,第343位。
答案 0 :(得分:0)
将此代码替换为您的代码:
- (void)createconnection {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
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>"
"<GetFlightDetailforSQAR xmlns=\"http://tempuri.org/\">"
"<FlightNo>100</FlightNo>"
"<UserBadgeNo>500</UserBadgeNo>"
"</GetFlightDetailforSQAR>"
"</soap:Body>"
"</soap:Envelope>"];
NSURL *url = [NSURL URLWithString: @"http://74.54.137.138:3052/Service.asmx?op=GetFlightDetailforSQAR"];
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://tempuri.org/GetFlightDetailforSQAR" forHTTPHeaderField:@"SOAPAction"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[req setHTTPMethod:@"POST"];
[req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (conn) {
webData = [[NSMutableData data] retain];
}
[pool release];
}
(void)parserDidStartDocument:(NSXMLParser *)解析器 {
NSLog(@“找到文件并开始解析”);
}
{
NSLog(@“START ELEMENT:%@”,elementName);
}
{
NSLog(@"String %@",string);
}
{
NSLog(@“END ELEMENT:%@”,elementName);
}