0
SOAP消息這是我的代碼:目標C:擊中URL使用POST方法
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];
而在connectionDidFinishLoading,我寫了這一個:
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>[email protected]</password><userId>posadmin</userId></arg0></login></soapenv:Body></soapenv:Envelope>
我傳遞有效載荷部分作爲SOAP消息 'requestMessage'。
讓我看看你的soap消息 – Hector 2012-03-07 09:28:09
請參閱編輯。 – utsabiem 2012-03-07 09:58:39
檢查您的xmlns網址 – Hector 2012-03-07 10:24:59