本文介绍了ASIHTTPRequest 400错误请求(肥皂)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IOS中使用ASIHTTPRequest.我有一个wsdl/soap Web服务.当我打电话给我的网站服务时,我收到了错误400错误的请求.我正在使用此代码:

I am using ASIHTTPRequest in IOS. I have aloso a wsdl/soap web services.when i call my web serives, i got the 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]);

NSLog向​​我显示:标头(空).

The NSLog show to me : headers (null).

我的第一个问题,为什么Headers为null?这正常吗?

My first question, why is Headers is null ? is this normal ??

在控制台中,我有400个错误的请求.在代表中,我这样做:

And in the console i have the 400 bad request.In the delegate, i do :

- (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错误的请求错误?我的要求是什么问题?还是问题出在我的肥皂上?

My question is : why the 400 bad request error ? what is the problem in my request ? or perhaps the problem is in my soap ?

感谢您的回答.

推荐答案

据我所知,在发出SOAP/WSDL请求时,您需要在请求中设置一些标头

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设置内容长度本身(不确定内容类型).不过,您将不得不自己添加SOAPAction标头.

ASIHTTPRequest sets the content-length itself (not sure about content-type). You will have to add the SOAPAction header yourself though.

这篇关于ASIHTTPRequest 400错误请求(肥皂)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 13:02