Im trying to get the session ID of another user in the same org by sending the following request by using the data from my enterprise wsdl and its an developer edition.

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">

But when i send this request i get

Missing SOAP ACTION header but in my wsdl i dont have the action ,its blank how to overcome this problem ?I got totaly struck over here since there is no action though its asking for action header.Following method handles the http request.

public string   processrrequest(string ep,string message,string method)

    HttpRequest req = new HttpRequest();
    req.setHeader('Content-Type', 'text/xml');
    Http http = new Http();
    HttpResponse res =http.send(req);
    //Dom.Document doc  = res.getbodyDocument();
    Dom.Document doc= new Dom.Document();
    return 'hai';

3 Answers 3


Looking at the Partner WSDL, the soapAction for the login operation is the empty string.

    <operation name="login">
        <soap:operation soapAction=""/>
        <!-- .... -->

So you would think that it should be added to the request as such:

HttpRequest req = new HttpRequest();
// ...
req.setHeader('SOAPAction', '');

However, as you found, passing the empty string to the SOAPAction header in the HTTPRequest results in the following response:

System.HttpResponse[Status=Server Error, StatusCode=500]

It would appear that the Apex HttpRequest.setHeader(string, string) won't send an empty or white-space only header. Without this header Salesforce rejects it as an invalid SOAP request.

After a bit of experimenting, it turns out the Salesforce Partner API doesn't really care what SOAPAction you send to it, as long as it is defined. Try it out with the following code and vary the value sent.

string sessionId = UserInfo.getSessionId();
HttpRequest req = new HttpRequest();
req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/u/31.0');
req.setHeader('Content-Type', 'text/xml; charset=UTF-8');
req.setHeader('SOAPAction', 'Wololo');
req.setBody('<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header><SessionHeader xmlns="urn:partner.soap.sforce.com"><sessionId>'+sessionId+'</sessionId></SessionHeader></env:Header><env:Body><query xmlns="urn:partner.soap.sforce.com"><queryString>Select Id, Name from Account limit 1</queryString></query></env:Body></env:Envelope>');
Http http = new Http();
HTTPResponse res = http.send(req)

Most values I've tried work, except for the empty string ('') and whitespace only (' ').

From the SOAPAction HTTP Header Field link in Keith's answer:

An HTTP client MUST use this header field when issuing a SOAP HTTP Request.


The presence and content of the SOAPAction header field can be used by servers such as firewalls to appropriately filter SOAP request messages in HTTP. The header field value of empty string ("") means that the intent of the SOAP message is provided by the HTTP Request-URI. No value means that there is no indication of the intent of the message.

So again, you need to define it. And in this case Salesforce doesn't use the value.


I figured out the problem and now im getting the session ID actually the mistake was in setting the action header initially i have setted Soap action as

req.setheader('SOAPAction',''); then i saw the wsdl where the SOAPACtion was like (SOAPAction,"") then tried as mentioned in wsdl req.setheader('SOAPAction','""'); and I got the output.

  • I'm surprised that is needed but well done for figuring it out.
    – Keith C
    Commented Jun 18, 2014 at 14:34

I am not sure why you are being asked for the action header.

This Partner WSDL example:

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    <n1:login xmlns:n1="urn:partner.soap.sforce.com">

is posted in the Salesforce documentation Step 1: Logging In Using the SOAP API so presumably is a working example.

Be sure to set the Content-Type header.

  • Hi @Keith C i tried with the example that u have given,But im getting the same error.Please check my question i have updated with the Http request handler method. Commented Jun 18, 2014 at 12:35
  • @ManojChandran Delete the line req.setHeader('SOAPAction',''); as the example posts no header not a header set to an empty string.
    – Keith C
    Commented Jun 18, 2014 at 12:38
  • @ Keith C I tried removing it ,but this too dint solve my problem same error is been thrown back.Actually I am trying this in my Developer edition and im trying to get session Id of another user who is also a system administrator and I'm supplying my username &pswd through an visual force page.Is my approach is correct? Commented Jun 18, 2014 at 12:44
  • You will have to also supply the security token. But that doesn't explain your error. Perhaps someone else can provide an answer.
    – Keith C
    Commented Jun 18, 2014 at 12:56
  • Im supplying my security token too...Thanks for your help Commented Jun 18, 2014 at 12:59

You must log in to answer this question.

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