gpt4 book ai didi

iOS SOAP WCF 调用问题 - HTTP 415 错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:13:06 25 4
gpt4 key购买 nike

我正在尝试发送 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";

}

如果我需要更改任何内容,请告诉我。

最佳答案

HTTP 415 错误 - 不支持的媒体类型

服务器拒绝为请求服务,因为实体 请求的格式不受请求资源的支持 对于请求的方法。

关于iOS SOAP WCF 调用问题 - HTTP 415 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17440806/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com