SOAP响应状态代码500

时间:2016-03-24 17:42:47

标签: objective-c soap response http-status-codes

我尝试在目标c,xcode中从iOS应用程序连接到SOAP API。首先,我使用wsdl2objc为访问生成端点存根,但我得到了响应状态代码500,如下所示:

  

{URL:http://api.tradera.com/v3/PublicService.asmx} {状态代码:500,headers {       “Cache-Control”=私有;       “内容长度”= 509;       “Content-Type”=“application / soap + xml; charset = utf-8”;       日期=“星期四,2016年3月24日17:36:24 GMT”;       Server =“Microsoft-IIS / 7.5”;       “X-AspNet-Version”=“4.0.30319”;       “X-Powered-By”=“ASP.NET”;   }}

现在我编写了自己的SOAP请求,并给出了相同的响应。它是服务器还是我的错?

我就是这样做的:

NSURL* url = [NSURL URLWithString:@"http://api.tradera.com/v3/PublicService.asmx"];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];
NSString* messageLength = [NSString stringWithFormat:@"%d",soapMessage.length];

[request addValue:@"api.tradera.com" forHTTPHeaderField:@"Host"];
[request addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue:messageLength forHTTPHeaderField:@"Content-Length"];
[request addValue:@"http://api.tradera.com/GetSearchResultAdvanced" forHTTPHeaderField:@"SOAPAction"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

NSURLResponse* response;
NSError* error;
NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

if ([((NSHTTPURLResponse*)response) statusCode] != 200) {
    [ErrorService alertResponseFault:((NSHTTPURLResponse*)response)];
}

0 个答案:

没有答案