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 ?
Best Answer
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)
Soap Request:
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.
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:
Method :
Post
Request Headers: (below)
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.