繁体   English   中英

在iPhone中使用NSXML解析器解析SOAP响应中的问题?

[英]Parsing issues in SOAP response using NSXML parser in iPhone?

我在我的应用程序中使用了SOAP Web服务。 我已将SOAP请求发送到服务器,并以XML格式获取结果。 我正在使用NSXML Parser解析数据。

我想获取数据“ true”,当我尝试解析内容应用程序时崩溃了,我无法解析该数据。

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

所以请帮帮我。

试试这个代码。

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]; 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM