2010-06-05 98 views
0

我正在嘗試進行肥皂調用。它是一個非常基本的呼叫,歡迎用戶輸出。返回值是xml格式。並且我收到以下錯誤。任何人都可以告訴我這個錯誤的含義。肥皂請求調用時出錯

下面的代碼表明,我已經

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

繼SOAP請求和POST請求的是,我得到的錯誤:

<?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> 

plz幫助我。我已經浪費了2天這樣一個簡單的代碼。

回答

1

你在第5行SOAP請求的錯誤:

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

被dubbled。做什麼的?

+0

這是因爲webservice需要xml輸入。所以我寫了這個標籤在web服務請求 – Jayshree 2010-06-12 05:49:21