2

We are using the enterprise WSDL file for an integration, during the query call of the WSDL we retrieve some account records. The issue we are facing is if some of the field value is null or no value been set, that node does not come in the response

Request:

    <x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn1="urn:enterprise.soap.sforce.com">
        <x:Header>
            <urn1:SessionHeader>
                <urn1:sessionId>
XXXXXXXXXXXX1_z6aJWLhP_Y57V1D2dE1L5mUqG9Ng4qPl4Mb4qvluCsL7
                </urn1:sessionId>
            </urn1:SessionHeader>
        </x:Header>
        <x:Body>
            <urn1:query>
                <urn1:queryString>SELECT Id,Sales_Team_ID__c, Name,customfield__c FROM Account
                </urn1:queryString>
            </urn1:query>
        </x:Body>
    </x:Envelope>

Response

<?xml version="1.0" encoding="UTF-8"?>
<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:Body>
        <queryResponse>
            <result>
                <done>true</done>
                <queryLocator xsi:nil="true"/>
                <records xsi:type="sf:Account">
                    <sf:Id>0010Q00000rTQBGreg</sf:Id>
                    <sf:Sales_Team_ID__c>20204</sf:Sales_Team_ID__c>
                </records>
            </result>
        </queryResponse>
    </soapenv:Body>

The customfield value is Null hence it didn't turn up in the response, what I want is to display an empty XML node even if the value is null.

The XSD defination

<element name="customfield__c " nillable="true" minOccurs="0" type="xsd:string"/>

Any thoughts?

1 Answer 1

0

I just ran a test directly from SOAPUI with a SOQL query from the Partner API.

In the case of an empty field it is returning with a xsi:nil="true" attribute rather than completely excluding the element for the blank field.

Request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com">
   <soapenv:Header>
      <urn:SessionHeader>   
          <urn:sessionId>00D00000000001!AQ0AQOi_RGZE_NotARealSessionId_UzrEZeK0qj</urn:sessionId>
      </urn:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <urn:query>
         <urn:queryString>Select Id, Name, BillingCity from Account</urn:queryString>
      </urn:query>
   </soapenv:Body>
</soapenv:Envelope>

Partial response

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sf="urn:sobject.partner.soap.sforce.com">
   <soapenv:Header>
      <LimitInfoHeader>
         <limitInfo>
            <current>412</current>
            <limit>15000</limit>
            <type>API REQUESTS</type>
         </limitInfo>
      </LimitInfoHeader>
   </soapenv:Header>
   <soapenv:Body>
      <queryResponse>
         <result xsi:type="QueryResult">
            <done>true</done>
            <queryLocator xsi:nil="true"/>
            <records xsi:type="sf:sObject">
               <sf:type>Account</sf:type>
               <sf:Id>0014000001djEf5AAE</sf:Id>
               <sf:Id>0014000001djEf5AAE</sf:Id>
               <sf:Name>Demo, Inc.</sf:Name>
               <sf:BillingCity>Woodland Hills</sf:BillingCity>
            </records>
            <records xsi:type="sf:sObject">
               <sf:type>Account</sf:type>
               <sf:Id>0014000001kEC1HAAW</sf:Id>
               <sf:Id>0014000001kEC1HAAW</sf:Id>
               <sf:Name>ABC</sf:Name>
               <sf:BillingCity xsi:nil="true"/>
            </records>
            <size>4</size>
         </result>
      </queryResponse>
   </soapenv:Body>
</soapenv:Envelope>
2
  • thanks @daniel, cant we do the same in enterprise wsdl. Can we do some modifications in the enterprise wsdl structure to have similar output as using partner wsdl (xsi:nil="true") Commented Dec 19, 2019 at 9:37
  • @ChaitaliMistry Any modifications you make to the WSDL will make no change to the data that the Salesforce SOAP APIs return. They will continue to omit the null fields in the response. Commented Dec 19, 2019 at 18:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .