"No action" error message was found while using SOAP webservice

Getting the following error when using the SOAP web service in an iOS application

"No Action header was found with namespace 'http://www.w3.org/2005/08/addressing' for the given message." 

The same webservice works fine in the SOAP user interface tool.

Below is the 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]; 

Full error response received from 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 was found with namespace 'http://www.w3.org/2005/08/addressing' for the given message.</s:Text> </s:Reason> <s:Detail> <a:ProblemHeaderQName>a:Action</a:ProblemHeaderQName> </s:Detail> </s:Fault> </s:Body> 

Any help is really appreciated.

+6
source share
3 answers

We had the same problem with an ASP.NET-based server (error message when using python / suds, the same request worked in SoapUi); after a lot of digging, we found that we needed to add a SOAP header (as an XML element) that contains the action; the actions in the Content-Type or SOAPAction headers were inadequate (but not painful). Here is an example of a successful request (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 and SUDS, we did this:

 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)) 

An action can be requested from a method, i.e. if you want to call client.service.foo method use

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

We found this by looking at the SoapUi protocol log. (We also tried Wireshark, but that didn't work, because we are trying to use an https server that we don’t have.)

+10
source

Enable

 [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"]; 
0
source

Finally, I can solve this problem, the format of the content and the format of the request are completely different from what I pass with the request

 Content-Type: application/soap+xml;charset=UTF-8;action="http://tempuri.org/IATCService/GetEvaluators" 

So the difference is that I need to pass the action with the content type.

Also, the Soap Envelop request is completely different from different namespaces.

 <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://tempuri.org/IATCService/GetEvaluators</a:Action> </s:Header>** <s:Body> <GetEvaluators xmlns=\"http://tempuri.org/\"/></s:Body> </s:Envelope> 

Since the header information is also completely different, we must indicate the action there.

Hope this will be helpful for someone who is facing the same problem.

0
source

Source: https://habr.com/ru/post/944547/


All Articles