ASIHTTPRequest 400 bad request (soap)
I am using ASIHTTPRequest in IOS. I have aloso a wsdl/soap web services. when i call my web serives, i got t开发者_如何学Che error 400 bad request. i am using this code :
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]);
The NSLog show to me : headers (null).
My first question, why is Headers is null ? is this normal ??
And in the console i have the 400 bad request. In the delegate, i do :
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSLog(@"headers: %@", [self.currentRequest responseHeaders]);
}
and it show tho me the :
"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";
My question is : why the 400 bad request error ? what is the problem in my request ? or perhaps the problem is in my soap ?
Thanks for your answers.
As far as I can tell, when making a SOAP/WSDL request, you need to set some headers in your request
Content-Type: text/xml
Content-Length: length of your message in bytes
SOAPAction: your SOAPAction goes here
ASIHTTPRequest sets the content-length itself (not sure about content-type). You will have to add the SOAPAction header yourself though.
精彩评论