I have implemented a web service in salesforce and generated the WSDL for the web service and provided it to the external system. However while invoking a call, we need to pass the session id in teh request. How can the external system get the session Id? Can we create a connected app and provide them the required details to get the session id?

1 Answer 1


First you need to set your endpoint of your server.

  1. Endpoint URL (Sandbox)-> https://test.salesforce.com/services/Soap/u/35.0
  2. Endpoint URL (Production)-> https://login.salesforce.com/services/Soap/u/35.0

Set your headers as below:

  1. SOAPAction-> ""
  2. Content-Type-> text/xml

And finally Body. Replace Login Id and Password with actual credentials:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com">
         <urn:username>Login ID</urn:username>

In response, you will get SessionId.

Once you've SessionId, set your endpoint URL as follows:


Again set Headers as follows:

  1. Authorization-> Bearer
  2. Content-Type-> application/json

And Body:

  • Thanks Rohit. However I am using a custom web service and the endpoint will contain the apex web service name. Should this call be included in the same request to the web service Or should this call be made first to retrieve the session details and then use it to call the web service Commented Oct 4, 2017 at 9:55
  • @SFDCLearner You will need 2 request. 1st to get sessionId and 2nd, use that sessionId to call your webservice. Refer Updated the answer. Commented Oct 4, 2017 at 10:01
  • Thanks Rohit! the second actual request can be made in xml as well i guess right? Let me try this and come back! Commented Oct 4, 2017 at 10:04
  • @SFDCLearner I haven't tried for xml but I think it's possible. Commented Oct 4, 2017 at 10:05

You must log in to answer this question.

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