2012-11-28 1 views
0

내 응용 프로그램에서 SOAP 웹 서비스를 사용했습니다. 나는 서버에 SOAP 요청을 보내고 XML 형식으로 답을 얻는다. NSXML 파서를 사용하여 데이터를 구문 분석합니다.iPhone에서 NSXML 파서를 사용하여 SOAP 응답에 구문 분석 문제가 있습니까?

콘텐츠 응용 프로그램을 구문 분석하려고 할 때 충돌이 발생하여 해당 데이터를 구문 분석 할 수없는 "true"데이터를 가져오고 싶습니다.

<ServiceFinalResult> 
<Response xmlns="http://aaaa.com/test/schemas/services/myaccounts/data/_1_0"> 
    true 
</Response> 
</ServiceFinalResult> 

제발 도와주세요.

+0

http://pastie.org/private/exl0v00mmqss1n5gxnpea – Pugal

+0

http://pastie.org/private/b430ecq5cwxbedhohy8y0w – Pugal

+0

http://pastie.org/private/pgi9tzmatbpocmfkkfviba – Pugal

답변

0

이 코드를 시도하십시오.

NSString *soapMessage = @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 
    "<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/\">\n" 
    "<soap:Body>\n" 
    "<name>testName</name>\n" 
    "</soap:Body>\n" 
    "</soap:Envelope>\n"; 

NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:webServiceUrl]; 

NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];    
[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; 
[req addValue:yourSoapAction forHTTPHeaderField:@"SOAPAction"]; 
[req addValue: msgLength forHTTPHeaderField:@"Content-Length"]; 
[req setHTTPMethod:@"POST"];  
[req setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; 

NSHTTPURLResponse* urlResponse = nil; 
NSError *error = [[[NSError alloc] init] autorelease]; 
NSData *webData = [NSURLConnection sendSynchronousRequest:req returningResponse:&urlResponse error:&error];