肥皂请求调用时出错

时间:2010-06-05 07:37:31

标签: iphone web-services soap nsxmlparser nsconnection

我正在尝试拨打肥皂。它是一个非常基本的电话,欢迎用户输出。返回值采用xml格式。我收到以下错误。任何人都可以告诉我这个错误意味着什么。

以下代码显示了我发布的soap请求和发布请求

NSString *soapMessage = [NSString stringWithFormat: @"<?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"
"<WelcomeXML xmlns=\"http://www.somewebsite.com/phpwebservice/index.php\">\n"
"<name>"
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<message>\n"
"<name>Hitesh</name>\n"
"</message>\n"
"</name>"
"</WelcomeXML>\n"
"</soap:Body>\n"
"</soap:Envelope>\n"];

NSLog(@"%@",soapMessage);

NSURL *url = [NSURL URLWithString:@"http://www.somewebsite.com/phpwebservice/index.php"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://www.somewebsite.com/phpwebservice/index.php/WelcomeXML" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

以下是我得到的错误:

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:string">SOAP-ENV:Client</faultcode><faultactor xsi:type="xsd:string"></faultactor><faultstring   xsi:type="xsd:string">error in msg parsing:
XML error parsing SOAP payload on line 5: Reserved XML Name</faultstring><detail  xsi:type="xsd:string"></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

请帮助我。我在这样一个简单的代码上浪费了2天。

1 个答案:

答案 0 :(得分:1)

第5行的SOAP请求中有错误:

"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"

被发现了。为什么?