ios - "No Action header was found" error message while using SOAP webservice -


getting following error while consuming soap webservice in ios app

"no action header found namespace 'http://www.w3.org/2005/08/addressing' given message." 

the same webservice working fine in soap ui tool.

following request format

nsstring *data = @"<soap:envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:tem=\"http://tempuri.org/\"> <soap:header></soap:header> <soap:body><tem:getevaluators></tem:getevaluators></soap:body> </soap:envelope>";  nsstring *url = @"webservice url"; nsdata *postdata = [data datausingencoding:nsutf8stringencoding allowlossyconversion:yes]; nsstring *postlength = [nsstring stringwithformat:@"%d", [postdata length]]; nsmutableurlrequest *request = [[nsmutableurlrequest alloc] init]; [request seturl:[nsurl urlwithstring:url]]; [request sethttpmethod:@"post"]; [request setvalue:postlength forhttpheaderfield:@"content-length"]; [request sethttpbody:postdata]; [request settimeoutinterval:20.0]; [request setvalue:@"application/soap+xml;charset=utf-8" forhttpheaderfield:@"content-type"]; [request setvalue:@"http://tempuri.org/iatcservice/getevaluators" forhttpheaderfield:@"soapaction"];  nsdata *urldata = [nsurlconnection sendsynchronousrequest:request returningresponse:&response error:&error]; 

complete error response received webservice

<s:envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> <s:header>     <a:action s:mustunderstand="1">http://www.w3.org/2005/08/addressing/fault</a:action> </s:header> <s:body>     <s:fault>         <s:code>             <s:value>s:sender</s:value>             <s:subcode>                 <s:value>a:messageaddressingheaderrequired</s:value>             </s:subcode>         </s:code>         <s:reason>             <s:text xml:lang="en-us">no action header found namespace 'http://www.w3.org/2005/08/addressing' given message.</s:text>         </s:reason>         <s:detail>             <a:problemheaderqname>a:action</a:problemheaderqname>         </s:detail>     </s:fault> </s:body> 

any appreciated.

we had same problem asp.net-based server (error message when using python/suds, same query worked in soapui); after lot of digging, found need add soap header (as xml element) contains action; having action in content-type or soapaction headers not enough (but not hurt either). here's example of successful query (from soapui):

<soap-env:envelope xmlns:ns0="..." xmlns:ns1="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope">    <soap-env:header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:action>http://www.foo.com/.../somejob/getparameters</wsa:action></soap-env:header>    <ns1:body>       <ns0:getparameters>...</ns0:getparameters>    </ns1:body> </soap-env:envelope> 

with python , suds, how did it:

from suds.sax.element import element wsans = ('wsa', "http://www.w3.org/2005/08/addressing") client.set_options(soapheaders = element('action', ns=wsans).settext(action)) 

the action can queried method, i.e. if want call method client.service.foo, use

action = client.service.foo.method.soap.action 

we found looking @ soapui http log. (we tried wireshark, not work because we're trying use https server don't own.)


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -