Using soapUI with Salesforce to test standard and custom web services response

soapUI is most common tool available to test Soap based web services, it also has capability to test REST web services. soapUI can be used to test Partner WSDL, enterprise WSDL, Tooling API, Metadata API to study capability and response from Salesforce before writing any code in Java, C# or any other language. In this article we will see, how we can leverage this tool to test enterprise WSDL from Salesforce.

You can download latest version of soapUI from here.

The WSDL file defines the Web service that is available to you. Your development platform uses this WSDL to generate an API to access the Force.com Web service it defines. You can either obtain the WSDL file from your organization’s Salesforce administrator or you can generate it yourself if you have access to the WSDL download page in the Salesforce user interface. You can navigate to the most recent WSDL for your organization from Setup by clicking “Develop | API | Enterprise WSDL” and download it.

Create new soapUI project by navigating to “File | New soapUI Project“. Provide project name and address of WSDL file downloaded from Salesforce.

Create New SoapUI project
Create New soapUI project

Login to Salesforce using soapUI

In newly created project, navigate to “login” binding and double click on Request1.

soapUI Salesforce login binding
soapUI Salesforce login binding

It will open split panel, left side contains sample request and right side contains response. We will be provided with sample request and need to enter required arguments, in this case username and password. Once done, click on green arrow above left panel, you would be presented with response on right panel (as shown in below image).

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
   <soapenv:Header>
      <urn:LoginScopeHeader>
         <urn:organizationId></urn:organizationId>
         <!--Optional:-->
         <urn:portalId></urn:portalId>
      </urn:LoginScopeHeader>
   </soapenv:Header>
   <soapenv:Body>
      <urn:login>
         <urn:username>user@jitendra.com</urn:username>
         <urn:password>SamplePassword</urn:password>
      </urn:login>
   </soapenv:Body>
</soapenv:Envelope>
soapUI response for Salesforce Login method
soapUI response for Salesforce Login method

copy “sessionId” and “serverURL” from response, as we will need it to test other methods.

Query Salesforce records using soapUI and SOQL

Now, open “query” soap binding from soapUI project menu and update URL with server URL returned in above login call.

Edit Endpoint URL of soapUI to query Salesforce record
Edit Endpoint URL of soapUI to query Salesforce record

Sample XML request in soapUI to get records using SOQL

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
   <soapenv:Header>
      <urn:PackageVersionHeader>
         <!--Zero or more repetitions:-->
         <urn:packageVersions>
            <urn:majorNumber>1</urn:majorNumber>
            <urn:minorNumber>1</urn:minorNumber>
            <urn:namespace></urn:namespace>
         </urn:packageVersions>
      </urn:PackageVersionHeader>
      <urn:MruHeader>

      </urn:MruHeader>
      <urn:QueryOptions>
         <!--Optional:-->
         <urn:batchSize>50</urn:batchSize>
      </urn:QueryOptions>
      <urn:SessionHeader>
         <urn:sessionId>00DU000000 0Mpcl!AQ 4AQMh.Hk2</urn:sessionId>
      </urn:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <urn:query>
         <urn:queryString>SELECT ID FROM Account</urn:queryString>
      </urn:query>
   </soapenv:Body>
</soapenv:Envelope>

Sample response from soapUI

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sf="urn:sobject.enterprise.soap.sforce.com">
   <soapenv:Header>
      <LimitInfoHeader>
         <limitInfo>
            <current>106</current>
            <limit>15000</limit>
            <type>API REQUESTS</type>
         </limitInfo>
      </LimitInfoHeader>
   </soapenv:Header>
   <soapenv:Body>
      <queryResponse>
         <result>
            <done>true</done>
            <queryLocator xsi:nil="true"/>
            <records xsi:type="sf:Account">
               <sf:Id>001U000001SxeQQIAZ</sf:Id>
            </records>
            <records xsi:type="sf:Account">
               <sf:Id>001U000001SxeQRIAZ</sf:Id>
            </records>
            <records xsi:type="sf:Account">
               <sf:Id>001U000001SxeRGIAZ</sf:Id>
            </records>
            <size>3</size>
         </result>
      </queryResponse>
   </soapenv:Body>
</soapenv:Envelope>

In same way, we can use any other standard or custom WSDL using soapUI.

Posted

in

by


Related Posts

Comments

8 responses to “Using soapUI with Salesforce to test standard and custom web services response”

  1. Nilesh Borse Avatar
    Nilesh Borse

    Can we check the other WSDL using this tool? i mean like SAP WSDL ?

  2. Nidhi Shekar Avatar
    Nidhi Shekar

    Hi Jitendra, Nice article. Have you tried a rest project with salesforce?

  3. Amulya Chandrashekar Avatar
    Amulya Chandrashekar

    Hi Jitendra,
    I want to ask external system to share the WSDL. I dont think they understand Salesforce security features and all. So along with Request and Response, what else should I ask them to add in Header part? I mean just Username, Password & Security Token are enough to establish secured connection?

  4. A Avatar
    A

    It seems that this is now part of ReadyUI and these instructions are no longer valid. The interface is completely different.

  5. Nagaraju Mogili Avatar
    Nagaraju Mogili

    Hi Jitendra,

    After Generating the WSDL, i was unable to see the Login option in the SOAP UI application.

    can you please guide me where can I find the Login option

  6. Bhavana galla Avatar
    Bhavana galla

    Hi Jitendra’s,
    That’s Awesome!
    Do you have an idea of how to store the response id and use it to send the request automatically onces it’s generated??

  7. Mustafa Avatar
    Mustafa

    please, how to add token to the login request? this the response:
    this the response : ‘Invalid username, password, security token; or user locked out. Are you at a new location? When accessing Salesforce–either via a desktop client or the API–from outside of your company’s trusted networks, you must add a security token to your password to log in. To get your new security token, log in to Salesforce. From your personal settings, enter Reset My Security Token in the Quick Find box, then select Reset My Security Token’

    1. said Avatar
      said

      add the value of the token after the password

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading