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?
Best Answer
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
Partial response