0

1行目の「soap:Envelope」開始タグの応答を取得するsoap Webサービスでこのリンクにアクセスすると、「soapody」の終了タグと一致しません。

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

2:10 PMrecevedstring--->soaperverServerはリクエストを処理できませんでした。--->

1行目の「soap:Envelope」開始タグが「soapody」の終了タグと一致しません。行1、位置343。

4

1 に答える 1

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

    NSLog(@"ファイルが見つかり、解析を開始しました");

}

  • (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName 名前空間URI:(NSString *)namespaceURI 修飾名:(NSString *)qName 属性:(NSDictionary *)attributeDict

{

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

}

  • (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)文字列

{

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

}

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

{

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

}

于 2012-05-01T05:20:13.640 に答える