I would like to call a SOAP web service created in salesforce, using Workbench. There are some samples for other types of web services from the apex workbook but not for SOAP :-(

My class contains 2 methods, each one containing an argument. Here is my code :

global class WsMyWebServiceClass {


webservice static List<Account>  getAccount(Integer  days) {

How can I test my method from Workbench ?

When I log in Workbench, I select Utilities | Rest Explorer

Get is selected by default

/services/data/v36.0 is prefilled

If I type /services/Soap/class/WsMyWebServiceClass and click on Execute, I get the following message :

GET not supported, this is a SOAP service, please use POST

So when I switch to Post, there is a Request Body that appears and I don't know what to fill in it ? Some JSON ?

When do I indicate that I'm using the getAccount method ?

If I use Post method, what do I need to fill for the 2 fields ?

/services/Soap/class/WsMyWebServiceClass... ????? Request body ?

enter image description here

  • Is it necessary to use workbench? Or you want to test the service you have built?
    – Saroj Bera
    Commented Jun 10, 2016 at 10:48
  • I know how to do that with SOAPUI tool (so I tested my WS with success). But I would like to understand how it could work with Workbench.
    – Pascal
    Commented Jun 11, 2016 at 13:10
  • check my answer.
    – Saroj Bera
    Commented Jun 15, 2016 at 4:46

2 Answers 2


Here is how I have tried using workbench to test a SOAP web service. Hope this helps.

First you have to get the session ID by passing a Soap request(I copied the request XML from SoapUI) to login method of the Salesforce SOAP API.

Service URL: /services/Soap/u/37.0

Method : Post

Request Headers: (below)

Content-Type: text/xml; charset=UTF-8
Accept: text/xml
SOAPAction: ''

Soap Request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com">
         <urn:password>****password+security token****</urn:password>

Execute it you will get the webservice response.

In the response you will get the session ID. Copy it and keep it in your notepad to call your Apex webservice.

enter image description here

For next call you have to use the following details.

Service URL: /services/Soap/class/sarojkbera/MyWebService (MyWebService is the Apex class exposed as Soap service)

Apex Class:

global class MyWebService {
    webService static String makeContact(String firstName, String lastName) {
        return 'Hello '+firstName+' ' +lastName;

Method : Post

Request Headers: (below)

Content-Type: text/xml; charset=UTF-8
Accept: text/xml
SOAPAction: ''

Soap Request:

Here I have used the generated Soap request from SoapUI.

Put the session ID (obtained in the previous step) in the request XML.

Execute it and you will get the Webservice response as below.

enter image description here

  • I have the following error message when I try to get the session Id <sf:exceptionCode>INVALID_LOGIN</sf:exceptionCode><sf:exceptionMessage>Login is restricted through MyDomain url only. </sf:exceptionMessage></sf:LoginFault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>
    – Pascal
    Commented Jun 16, 2016 at 16:41
  • As you said, I have no problem using the enterpise.wsdl to get my sessionId using SOAPUI. When I paste exactly the same request in Workbench, I got this error : Login is restricted through MyDomain url only
    – Pascal
    Commented Jun 16, 2016 at 16:43

Thanks so much for your detailed answer.

I can get the sessionId from SOAPUi or from Developer Console : system.debug(UserInfo.getSessionId()); So this is not a problem.

But I followed your advice for my web service : Method : POST


Request Header : As indicated by Saroj

Request Body : enter image description here

You must log in to answer this question.

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