ASIHTTPRequest 400错误请求(soap)



我在IOS中使用ASIHTTPRequest。我有一个wsdl/soap web服务。当我调用我的web serives时,我收到了错误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)。

我的第一个问题,为什么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标头。

最新更新