0

当我在肥皂网络服务中点击此链接时,第 1 行上的“soap:Envelope”开始标记与“soapody”的结束标记不匹配。

http://74.54.137.138:3052/Service.asmx?op=GetFlightDetailforSQAR

2:10 PMrecevedstring--->sooperverServer 无法处理请求。--->

第 1 行的“soap:Envelope”开始标签与“soapody”的结束标签不匹配。第 1 行,位置 343。

4

1 回答 1

0

将此代码替换为您的代码:

-(无效)创建连接{

   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 *)parser {

    NSLog(@"找到文件并开始解析");

}

  • (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURIqualifiedName:(NSString *)qName 属性:(NSDictionary *)attributeDict

{

NSLog(@"起始元素:%@",elementName);

}

  • (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string

{

NSLog(@"String %@",string);

}

  • (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURIqualifiedName:(NSString *)qName

{

NSLog(@"END ELEMENT :%@",elementName);

}

于 2012-05-01T05:20:13.640 回答