Это мой код:
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
NSURL *url = [NSURL URLWithString:urlString];
theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest addValue:@"gzip" forHTTPHeaderField:@"accept-encoding"];
[theRequest addValue:@"en-us" forHTTPHeaderField:@"accept-language"];
[theRequest addValue:@"[application/soap+xml, application/dime, multipart/related, text/*]" forHTTPHeaderField:@"Accept"];
//[theRequest addValue:@"user_agent" forHTTPHeaderField:@"user-agent"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [requestMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"REQUEST\n%@", theRequest);
webConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
И в связи с DidFinishLoading я написал это:
NSString *theXML = [[NSString alloc] initWithBytes: [dataFromWebService mutableBytes] length:[dataFromWebService length] encoding:NSUTF8StringEncoding];
NSLog(@"XML:\n%@", theXML);
Теперь, когда я запускаю код, я получаю сообщение об ошибке:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Error reading XMLStreamReader.</faultstring></soap:Fault></soap:Body></soap:Envelope>
Почему я получаю эту ошибку, а не фактический ответ? Это ошибка на стороне приложения или на стороне сервера?
РЕДАКТИРОВАТЬ: Это SOAP-сообщение:
Content-Type: text/xml; charset=utf-8
Headers: {Accept=[application/soap+xml, application/dime, multipart/related, text/*], cache-control=[no-cache], Content-Length=[407], content-type=[text/xml; charset=utf-8], host=[172.16.253.74:8080], pragma=[no-cache], SOAPAction=["urn:Login"], user-agent=[Axis/1.4]}
Payload: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><login xmlns="http://tilloperations.services.mpos.tcs.com/"><arg0 xmlns=""><password>Posadmin@1</password><userId>posadmin</userId></arg0></login></soapenv:Body></soapenv:Envelope>
Я передаю часть полезной нагрузки как SOAP-сообщение 'requestMessage'.