Using SOAP UI tool we can perform many operations:
As part of Integration we can see 2 parts:
- Request
- Response
1. Envelope: which is generally we call as packet. While sending the request to external system the request will go as packet.
2. Header: This will carry additional information about request like session id.
3. Body: Contains actual message. If the request is Login call then Username and password will be the body. If a request is Insert operation then the body will be object name and field’s names along with data to those specific fields.
Once we consume WSDL file in SOAP UI we can see a list of operations that are available in the left-hand side those are called as “SOAP API calls”.
SOAP API Calls: Are classified into 3 types:[Below calls are not specific to SOAP UI tool it is generic to SOAP API]
a. Core Calls [Like CRUD operations on records and login will comes under core calls- Here CRUD=Create Read Update Delete ]
b. Describe calls [This calls will help to retrieve meta data like objects, fields, pagelayouts,tabs]
c. Utility calls [This calls helps to retrieve user related info, setting/resetting password to user.]
Note: The above mentioned 3 types of calls can be performed on all custom and standard objects.
Breakdown of the endpoint URI:
https://login.salesforce.com/services/Soap/c/39.0/0DF28000000DuLl
· https://—Specifies secure HTTP.
· login.salesforce.com—Top-level domain for a login request.
· /services/Soap—Specifies that we’re making a SOAP API request.
· /c—Specifies that we’re using the enterprise WSDL. Use /u for the partner WSDL.
· /36.0—API version number. The v prefix is missing because some APIs include it before the version number, and some don’t. This behavior is just a quirk of Salesforce APIs.
· /0DF36000000LHZw—Package version number.
We will see some examples of all the above types of calls.
Core Calls:
Login call:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
<soapenv:Body>
<urn:login>
<urn:username>manju@learning.com</urn:username>
<urn:password>9989008211aa</urn:password>
</urn:login>
</soapenv:Body>
</soapenv:Envelope>
Response received from Login call :
-------------------------------------
<serverUrl>[URL of the respective Salesforce Org]</serverUrl>
<sessionId>[Session ID for the new session established]</sessionId>
Login call: Without user name and password:
We can’t do only login call without user name and password. But in one login call if we include some other call then we can get request without any errors.
Example: In the below example in login call itself I am trying to create a new record without user name and password. For doing this I have taken session ID of a particular user. The reason behind combining this login call with some other call is login call output(Response) is session Id but we are trying to pass session id in the below example so the system will not understand what is expected J that’s the reason why we are combining login call with create call.
EXAMPLE 1:
************
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<urn:SessionHeader> <urn:sessionId>00D28000001xtt5!ARcAQLAdk0WSU_YNJzmcYCr0WDX.85b0..d68QyyDcJ8Tz.Ml1mPYUKAFYoYPZhspHfZHFrdVNuBivUzPS2bMifgS0hL9MGT</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:create>
<!--Zero or more repetitions:-->
<urn:sObjects xsi:type="urn1:Objects_Daily_Count__c">
<Name> SOAP API test1</Name>
<!--Zero or more repetitions:-->
</urn:sObjects>
Example 2: To Create single record: Highlighted attribute we need to add to perform create call.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>00D28000001xtt5!ARcAQMc5CdyAEHWdkawIgguOod4yvvRAOs4oqLjCNAFHu8ZetX3k.4r3.m2LqQeHBIKn75jQlJJtQoKwOW1hq6fkP7f.Mg40
</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:create>
<!--Zero or more repetitions:-->
<urn:sObjects xsi:type="urn1:Objects_Daily_Count__c">
<!--Zero or more repetitions:-->
<Name> SOAP API test1</Name>
</urn:sObjects>
</urn:create>
</soapenv:Body>
</soapenv:Envelope>
Response from create call:
<result>
<id>001U0000016oRZVIA2</id>
<success>true</success>
</result>
Example 3:To Create multiple records:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>00D28000001xtt5!ARcAQMc5CdyAEHWdkawIgguOod4yvvRAOs4oqLjCNAFHu8ZetX3k.4r3.m2LqQeHBIKn75jQlJJtQoKwOW1hq6fkP7f.Mg40</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:create>
<urn:sObjects xsi:type="urn1:Objects_Daily_Count__c">
<Name> SOAP API test3</Name>
</urn:sObjects>
<urn:sObjects xsi:type="urn1:Objects_Daily_Count__c">
<Name> SOAP API test4</Name>
</urn:sObjects>
</urn:create>
</soapenv:Body>
</soapenv:Envelope>
Example 4:To Create records of multiple objects at a time:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>00D28000001xtt5!ARcAQMc5CdyAEHWdkawIgguOod4yvvRAOs4oqLjCNAFHu8ZetX3k.4r3.m2LqQeHBIKn75jQlJJtQoKwOW1hq6fkP7f.Mg40</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:create>
<urn:sObjects xsi:type="urn1:Account">
<Name>Feedback</Name>
</urn:sObjects>
<urn:sObjects xsi:type="urn1:Contact">
<FirstName>Anupam</FirstName>
<LastName>Rastogi</LastName>
</urn:sObjects>
</urn:create>
</soapenv:Body>
</soapenv:Envelope>
Example 5: Creating related records having a parent-child relationship using the create() API:
In this case we need an external Id to relate parent child records
In this case we need an external Id to relate parent child records
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>00D28000001xtt5!ARcAQMc5CdyAEHWdkawIgguOod4yvvRAOs4oqLjCNAFHu8ZetX3k.4r3.m2LqQeHBIKn75jQlJJtQoKwOW1hq6fkP7f.Mg40</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:create>
<urn:sObjects xsi:type="urn1:Account">
<Name>Sample Account Two</Name>
<!-- Siebel_Id__c is the External Id field present on Account object -->
<SLASerialNumber__c>Manju</SLASerialNumber__c>
</urn:sObjects>
<urn:sObjects xsi:type="urn1:Contact">
<FirstName>Anupam</FirstName>
<LastName>Rastogi</LastName>
<urn1:Account>
<SLASerialNumber__c>Manju</SLASerialNumber__c>
</urn1:Account>
</urn:sObjects>
</urn:create>
</soapenv:Body>
</soapenv:Envelope>
Example 6 : Performing Upsert
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>00D28000001xtt5!ARcAQHn3O_B4gCXSOPtEbieOoNHa6JFRIXp_7EN9ug9g14IRdfjoeKXRg1GfltZc0aJF7mpK0_w0DGsGc5X6RDCOeCf9xepX</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:upsert>
<urn:externalIDFieldName>Id</urn:externalIDFieldName>
<!--Zero or more repetitions:-->
<urn:sObjects xsi:type="urn1:Objects_Daily_Count__c" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--Zero or more repetitions:-->
<Name>My World</Name>
<Id>a012800001EePNrAAN</Id>
</urn:sObjects>
</urn:upsert>
</soapenv:Body>
</soapenv:Envelope>
Example 7: Using Update
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<urn:SessionHeader>
<sessionId>00D28000001xtt5!ARcAQMc5CdyAEHWdkawIgguOod4yvvRAOs4oqLjCNAFHu8ZetX3k.4r3.m2LqQeHBIKn75jQlJJtQoKwOW1hq6fkP7f.Mg40</sessionId>
</urn:SessionHeader>
<urn:AllOrNoneHeader>
<urn:allOrNone>true</urn:allOrNone>
</urn:AllOrNoneHeader>
</soapenv:Header>
<soapenv:Body>
<urn:update>
<urn:sObjects xsi:type="urn1:Account">
<Name>Test Account Sample</Name>
<Industry>Agriculture</Industry>
<Type>Prospect</Type>
<Id>0012800001H5Hn1AAF</Id>
</urn:sObjects>
</urn:update>
</soapenv:Body>
</soapenv:Envelope>
The parent of a record can be modified using this API. This scenario can utilize even the foreign key to change the parent, if not the Salesforce ID of the parent record. In this example, the parent Account record of contact will be updated.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<urn:SessionHeader>
<sessionId>00D28000001xtt5!ARcAQMc5CdyAEHWdkawIgguOod4yvvRAOs4oqLjCNAFHu8ZetX3k.4r3.m2LqQeHBIKn75jQlJJtQoKwOW1hq6fkP7f.Mg40</sessionId>
</urn:SessionHeader>
<urn:AllOrNoneHeader>
<urn:allOrNone>true</urn:allOrNone>
</urn:AllOrNoneHeader>
</soapenv:Header>
<soapenv:Body>
<urn:update>
<urn:sObjects xsi:type="urn1:Contact">
<Id>0032800000zemC9</Id>
<LastName>Updating Parent contact lastname record.</LastName>
<urn1:Account>
<SLASerialNumber__c>Manju</SLASerialNumber__c>
</urn1:Account>
</urn:sObjects>
</urn:update>
</soapenv:Body>
</soapenv:Envelope>
Example 8: Making a Query Call
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
<soapenv:Header>
<urn:SessionHeader> <urn:sessionId>00D28000001xtt5!ARcAQMc5CdyAEHWdkawIgguOod4yvvRAOs4oqLjCNAFHu8ZetX3k.4r3.m2LqQeHBIKn75jQlJJtQoKwOW1hq6fkP7f.Mg40</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:query>
<urn:queryString>SELECT Name FROM Objects_Daily_Count__c where Name='SOAP API test3'</urn:queryString>
</urn:query>
</soapenv:Body>
</soapenv:Envelope>
Example 9: Query Call(Parent to Child):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>00D28000001xtt5!ARcAQMc5CdyAEHWdkawIgguOod4yvvRAOs4oqLjCNAFHu8ZetX3k.4r3.m2LqQeHBIKn75jQlJJtQoKwOW1hq6fkP7f.Mg40</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:query>
<urn:queryString>SELECT Id,Name,(Select Id from Contacts) FROM Account</urn:queryString>
</urn:query>
</soapenv:Body>
</soapenv:Envelope>
Example 10:Query Call(Child to Parent)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>00D28000001xtt5!ARcAQMc5CdyAEHWdkawIgguOod4yvvRAOs4oqLjCNAFHu8ZetX3k.4r3.m2LqQeHBIKn75jQlJJtQoKwOW1hq6fkP7f.Mg40</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:query>
<urn:queryString>Select Id,Account.Name from Contact</urn:queryString>
</urn:query>
</soapenv:Body>
</soapenv:Envelope>
Describe calls:
DescribeSobjects : Which will retrieve list of mentioned objects with objects fields information.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>00D28000001xtt5!ARcAQMc5CdyAEHWdkawIgguOod4yvvRAOs4oqLjCNAFHu8ZetX3k.4r3.m2LqQeHBIKn75jQlJJtQoKwOW1hq6fkP7f.Mg40</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:describeSObjects>
<!--0 to 100 repetitions:-->
<urn:sObjectType>Account</urn:sObjectType>
<urn:sObjectType>Contact</urn:sObjectType>
</soapenv:Body>
</soapenv:Envelope>
Utility Calls:
EmptyRecycleBin() is used to hard delete the records
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>00D28000001xtt5!ARcAQMc5CdyAEHWdkawIgguOod4yvvRAOs4oqLjCNAFHu8ZetX3k.4r3.m2LqQeHBIKn75jQlJJtQoKwOW1hq6fkP7f.Mg40
</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:emptyRecycleBin>
<!--1 or more repetitions:-->
<urn:ids>a012800000vedFnAAI</urn:ids>
</urn:emptyRecycleBin>
</soapenv:Body>
</soapenv:Envelope>
Example tools that support SOAP API calls:
The below are the few famous tools which are used for SOAP API calls, these tools simulate the integration calls.
SOAP UI : Open source tool which requires to download into local machine.
Postman: This is a chrome extension no need to download
Postman: This is a chrome extension no need to download
Comments
Post a Comment