2

SOAP リクエストを送信しようとしていますが、「HTTP 415 サポートされていないメディア」エラーが返されます。

以下は私のコードです

NSString *soapMessage = [NSString stringWithFormat:@"<Envelope xmlns=\"http://www.w3.org/2003/05/soap-envelope\"><Body><GetCity xmlns=\"http://tempuri.org/\"><SearchString></SearchString><SearchZone></SearchZone></GetCity></Body></Envelope>"];



NSURL *url=[NSURL URLWithString:@"http://ws.abcxyz.com/abcxyz1/Service1.svc?wsdl"];

NSMutableURLRequest *theRequest= [NSMutableURLRequest requestWithURL:url];

NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];

[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/IService1/GetCity" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

if (theConnection) {

    NSMutableData *responseData = [NSMutableData data];
    NSLog(@"success %d", [responseData length]);
} else {
    NSLog(@"failed");
    //messageTextView.text=@"Failed";

}

何かを変更する必要がある場合はお知らせください。

4

1 に答える 1

2

HTTP 415 エラー - サポートされていないメディア タイプ

リクエストのエンティティが、リクエストされたメソッドのリクエストされたリソースでサポートされていない形式であるため、サーバーはリクエストの処理を拒否しています。

于 2013-07-04T06:17:26.400 に答える