Following on from my other post about my webservice that returns a generic xml doc:

Can I process xml results doc from webservice callout?

I've got some example code to call the webservice and process the response using the Http class from here:


But, when I put my values in, I'm getting an error returned in the HttpResponse from the webservice:

[Status=Internal Server Error, StatusCode=500] Server did not recognize the value of HTTP Header SOAPAction: http://xxx.xxx.xxx.xxx/MBSGPQueryServices

I thought the SOAPAction was basically the name of the function being called (i.e. MBSGPQueryServices), what am I missing?

Many thanks for any responses as this is driving me crazy!

Regards, David

Code shown below:

Map<string,string> GPSXMLResponse = new Map<string,string>();

string xmlLength=string.valueof(xmlDoc.length());

HttpRequest req = new HttpRequest();
req.setHeader('Content-Type', 'text/xml; charset=utf-8');
req.setHeader('SOAPAction', 'http://xxx.xxx.xxx.xxx/MBSGPQueryServices');

string b = '<?xml version="1.0" encoding="utf-8"?>';
b += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
b += '<soap:Body>';
b += '<MBSGPQueryServices xmlns="http://xxx.xxx.xxx.xxx">';
b += '<ServiceDocType>' + xmlDoc + '</ServiceDocType>';
b += '</MBSGPQueryServices>';
b += '</soap:Body>';
b += '</soap:Envelope>';

System.debug('About to req.setBody(b):'+b);


System.debug('After req.setBody(b):'+b);

Http http = new Http();
HTTPResponse res = http.send(req);

2 Answers 2


As far as I can tell from this page: unraveling the mystery of soap you can leave it empty because the action is already defined in the soap request URI:

req.setHeader('SOAPAction', '');
  • As an example, salesforce.com's SOAP interface expects a SOAPAction value of "" in all cases that I've ever seen. But not all SOAP is created equal, so it is possible that their SOAPAction is actually correct. Some SOAP implementations expect an "intent" through SOAPAction/action (as in your link), while others ignore SOAPAction and use the request URI and/or SOAP envelope to determine the appropriate action to take. That said, the URI of the intent isn't related to the actual URI that is requested over HTTP(S). It could be "urn:MBSGPQueryServices", for example.
    – sfdcfox
    Commented Oct 25, 2013 at 18:59

The WSDL will describe what you should set the soapAction header to, inside the binding section of the wsdl, there an operation element, and inside that there's another element that specifies the soapAction, e.g.

   <binding name="SoapBinding" type="tns:Soap">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="login">
            <soap:operation soapAction="urn:foo"/>

Also note that the actual HTTP header should be quoted, i.e for the soapAction above, the actual HTTP header should be

SOAPAction: "urn:foo"

and not

SOAPAction: urn:foo

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .