如何解决ASIHTTPRequest 400错误请求soap
我在IOS中使用ASIHTTPRequest。我有一个wsdl / soap Web服务。 当我打电话给我的网站服务时,我收到了错误400错误的请求。我正在使用此代码:NSData *xmlData = // I construct the soap message witk soapui
NSURL *url = [NSURL URLWithString:@\"https:myUrlWSDL\"];
self.currentRequest = [ASIFormDataRequest requestWithURL:url];
[self.currentRequest appendPostData:xmlData];
[self.currentRequest setDelegate:self];
[self.currentRequest startAsynchronous];
[[currentRequest requestHeaders] description];
NSLog(@\"Headers %@\",[currentRequest requestHeaders]);
NSLog向我展示:标头(空)。
我的第一个问题,为什么Headers为null?这正常吗?
在控制台中,我有400个错误的请求。
在代表中,我这样做:
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSLog(@\"headers: %@\",[self.currentRequest responseHeaders]);
}
它告诉我:
\"Cache-Control\" = \"no-store,no-cache,must-revalidate,post-check=0,pre-check=0\";
Connection = close;
\"Content-Encoding\" = gzip;
\"Content-Length\" = 285;
\"Content-Type\" = \"text/xml; charset=utf-8\";
Date = \"Fri,10 Jun 2011 01:25:40 GMT\";
Expires = \"Thu,19 Nov 1981 08:52:00 GMT\";
Pragma = \"no-cache\";
Server = Apache;
\"Set-Cookie\" = \"symfony=...4; path=/\";
Vary = \"Accept-Encoding,User-Agent\";
\"X-Powered-By\" = \"PHP/5.3.3\";
我的问题是:为什么400错误请求错误?我的要求是什么问题?还是问题出在我的肥皂上?
感谢您的回答。
解决方法
据我所知,在发出SOAP / WSDL请求时,您需要在请求中设置一些标头
Content-Type: text/xml
Content-Length: length of your message in bytes
SOAPAction: your SOAPAction goes here
ASIHTTPRequest设置内容长度本身(不确定内容类型)。但是,您将不得不自己添加SOAPAction标头。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。