12 April 2015

Sample Salesforce Enterprise SOAP create

This is a sample SOAP Create using Enterprise WSDL. Note that we only passing the session Id  on the header information since we don't need the others and that the envelop must be posted to the ServerURL you got from the login call as per described in this blogpost.


<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>Session ID from login call</urn:sessionId>
      </urn:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <urn:create>
         <urn:sObjects xsi:type="Account">
            <Name>Sample Account (Enterprise)</Name>
         </urn:sObjects>
      </urn:create>
   </soapenv:Body>
</soapenv:Envelope>

Below is the sample SOAP response:


<soapenv:Envelope 
     xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"    
     xmlns="urn:enterprise.soap.sforce.com">
   <soapenv:Header>
      <LimitInfoHeader>
         <limitInfo>
            <current>9</current>
            <limit>15000</limit>
            <type>API REQUESTS</type>
         </limitInfo>
      </LimitInfoHeader>
   </soapenv:Header>
   <soapenv:Body>
      <createResponse>
         <result>
            <id>0017000001ExVRDAA3</id>
            <success>true</success>
         </result>
      </createResponse>
   </soapenv:Body>
</soapenv:Envelope>

NOTE:

The <createResponse> node will have the result of the call. The <id> will contain the record Id in SFDC for the record you are creating and the <success> will tell whether the call is successful or not.

*I noticed that SoapUI 5.0.0 does not automatically add the xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance". This is important when you are setting the object type <urn:sObjects> tag.

No comments:

Post a Comment