1

iPhone で Web サービス SOAP にリクエストを送信すると、エラーが発生します。どうすれば修正できますか?

これが私が受け取っているメッセージです。

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
  <soap:Fault>
     <faultcode>soap:Client</faultcode>
     <faultstring>Server did not recognize the value of HTTP Header SOAPAction: HelloWorld.</faultstring>
      <detail />
   </soap:Fault>
 </soap:Body>
 </soap:Envelope>

これが私のobjective-cコードです

-(IBAction)buttonClick:(id)sender
{
recordResults = FALSE;

NSString *soapMsg =
[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"
 "<HelloWorld xmlns=\"http://tempuri.org/\" />\n"
 "</soap:Body>\n"
 "</soap:Envelope>\n"];

//---print it to the Debugger Console for verification---
NSLog(soapMsg);

NSURL *url = [NSURL URLWithString: @"http://servicing2.rotanet.com.tr/service1.asmx"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self];

//---set the various headers---
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];
[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req addValue:@"HelloWorld" forHTTPHeaderField:@"SOAPAction"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];

//---set the HTTP method and body---
[req setHTTPMethod:@"POST"];
[req setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];


theConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (theConnection) {
    webData = [[NSMutableData data] retain];
}
}

私はこれに2日間取り組んできました。そして私は夢中になります。何か提案はありますか?

4

3 に答える 3

0

間違った SOAPAction を渡したと思います

これを試して

[req addValue:@"http://tempuri.org/HelloWorld" forHTTPHeaderField:@"SOAPAction"]
于 2013-05-08T12:30:05.070 に答える
0

サーバーは、送信中のリクエストに対応するサービスを見つけることができません。作成した SOAP トランザクションは以下を送信します。

"<HelloWorld xmlns=\"http://tempuri.org/\" />\n"

クライアントがサーバーが理解することを期待するもの。この場合、サーバーはトランザクション リクエストを理解せず、以下を返します。

  Server did not recognize the value of HTTP Header SOAPAction: HelloWorld.

HelloWorldアクションがサーバー上の何にも対応していないことを除けば、SOAP クライアントは問題ないようです。

サーバーをチェックして、それが有効なアクションであることを確認し、クライアントが有効なアクション リクエストを送信するように修正するか、送信しているリクエストにサーバーが応答するように修正します。

于 2013-05-08T11:19:17.277 に答える