parsing器错误错误域= NSXMLParserErrorDomain代码= 4“操作无法完成。”

我打电话给一个Web服务如下:

-(void)verifyEmailAndPasswordWebservices { NSString *MD5Password = [ self MD5]; NSLog(@"text field password %@",txt_Password.text); NSLog(@"converted password %@",MD5Password); NSString *soapMsg =[NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>" "<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/\" xmlns:tns=\"http://php:8393/includes/webservice\">" "<SOAP-ENV:Body>" "<ns1:LoginUserRequest xmlns:ns1=\"http://schemas.xmlsoap.org/soap/envelope/\">" "<email xsi:type=\"xsd:string\">%@</email>" "<pass xsi:type=\"xsd:string\">%@</pass>" "</ns1:LoginUserRequest>" "</SOAP-ENV:Body>" "</SOAP-ENV:Envelope>",txt_EmailOrMobile.text,MD5Password]; //---print it to the Debugger Console for verification--- NSLog(@"soapMsg..........%@",soapMsg); NSURL *url = [NSURL URLWithString:@"http://10.0.0.115:8393/includes/webservice/login1.php"]; req = [NSMutableURLRequest requestWithURL:url]; //---set the headers--- NSString *msgLength = [NSString stringWithFormat:@"%d",[soapMsg length]]; [req addValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [req addValue:@"http://10.0.0.115/includes/webservice/login1.php/LoginUser" forHTTPHeaderField:@"SoapAction"]; [req addValue:msgLength forHTTPHeaderField:@"Content-Length"]; //---set the HTTP method and body--- [req setHTTPMethod:@"POST"]; [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]]; // [activityIndicator startAnimating]; conn = [[NSURLConnection alloc] initWithRequest:req delegate:self]; if (conn) { webData = [[NSMutableData data] retain]; } } 

当我得到的答复,给我下面的错误:

DONE。 收到字节:422显示XML(空)parsing器错误错误域= NSXMLParserErrorDomain代码= 4“操作无法完成(NSXMLParserErrorDomain错误4.)”

我在互联网上search了很多。 但无法find任何东西。 任何帮助,请。

NSXMLParserErrorDomain error 4意味着XMLparsing器被赋予一个空文档。 这表明input或者是null,或者在它被提供给parsing器之前设法改变它。

我有更好的看你的代码。 问题不是你没有得到回应。 只是你不在等。 你发送的请求是asynchronous的,但你试图直接填写你的webDatavariables(即同步)。

另一个可能的共振可能是没有根标签。 例如:这样的一个XML数据—>


2011-12-22

 <days_remaining> 0 </days_remaining> 

在你的编码方法上试试这个代码

 NSString *theXML = [[NSString alloc] initWithBytes: [_responseData mutableBytes] length:[_responseData length] encoding:NSUTF8StringEncoding];