Monday, 8 September 2014

Salesforce WSDL testing using Soap UI

In this post I am going to discuss about how to test Salesforce WSDL using Soap UI. This is pretty basic stuff but for beginners this might be helpful.

You need to download the WSDL from your application from Setup -> Develop -> API -> Generate Enterprise WSDL. 

Copy and save the WSDL into a .wsdl file.

Import this WSDL in Soap UI. It will import methods like Create, Convert Lead, login, update, upsert etc.

First we need to get a session Id to access data in salesforce. To get this, we need to call login method in the WSDL.

The login method input should look like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
   <soapenv:Header></soapenv:Header>
   <soapenv:Body>
      <urn:login>
          <!--Salesforce Username:-->
         <urn:username>khadar.pathan@gmail.com</urn:username>
           <!--password appended with session token:-->    <urn:password>NewPasswordc4w5ePZbF3dBokl1BrWr</urn:password>
      </urn:login>
   </soapenv:Body>
</soapenv:Envelope> 

You need to get the session token from below location in the application. 
This will send an email to your account with session token. You need to append your password and this token if you are trying to login to application from anything apart from a browser (like SOAP, Force.com IDE etc). 

You might get this error if you do not give session token "Invalid username, password, security token; or user locked out."

The output of above request gives server URL and session Id.

Using this session Id in Soap header and URL as service end point, you can create, delete, update, upsert or do any operation from the WSDL. If you do not change the service end point, you will get error "Destination URL not reset. The URL returned from login must be set in the SforceService".

In the below example, I have created a new Account. Sample Soap messages to create the data can be found at https://developer.salesforce.com/page/Sample_SOAP_Messages


Hope this helps!!

1 comment:

  1. Thank you for posting this detailed step-by-step guide. I will definitely try it out to customize my own CRM instance.

    ReplyDelete