0
を使用してSOAPメッセージとURLを叩く:Objective Cのは:これは私のコードで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で、私はこの1つを書いた:
今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メッセージです。
あなたのsoapMessageを見せてください – Hector
編集をご覧ください。 – utsabiem
あなたのxmlnsのURLを確認してください – Hector