function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
karthik karthikkarthik karthik 

How to send null value fields from salesforce

Hi,

I have created a custom web service in salesforce using the custom wsdl i returned opportunity fields. In some opportunity fields have null values, how to send null value fields from salesforce.
For testing purpose i used this custom wsdl in SopaUI tool i couldn't able to see null value fileds in soap repsonse. How to display null value fileds also in soap response from salesforce.

Please its some urgent can anyone help me.
Thanks in advance.
Daniel BallingerDaniel Ballinger
Can you clarify how you aren't seeing the nulls in the response? Ideally include the definition of your Apex class that defines the web service and a sample SOAP request/response.
karthik karthikkarthik karthik
Hi Dan,

Thanks for your response, the following is the request and reponse.

Request:
<soapenv:Body>
      <get:IdDecrypt>
         <get:query>select id,name,OrderNumber__c,CurrentGenerators__c from opportunity</get:query>
         <get:OppId>PbFnkCfJzFSNBdditD2NiyO/P+CzZC9g+hFL+EPL96XsmxrCCXZbOpr40Q4RFldq</get:OppId>
      </get:IdDecrypt>
   </soapenv:Body>

Response:
<soapenv:Body>
      <IdDecryptResponse>
         <result xsi:type="Opportunity">
            <Id>0069000000fAtNdAAK</Id>
            <Name>test TLS</Name>
         </result>
      </IdDecryptResponse>
   </soapenv:Body>
</soapenv:Envelope>

I'm using custom wsdl here, in the request i'm trying to fetch four fields out of two fileds have null values and i didn't get null fileds in response. How to get null value fields also in response. 

Expecting Output:

Response:
<soapenv:Body>
      <IdDecryptResponse>
         <result xsi:type="Opportunity">
            <Id>0069000000fAtNdAAK</Id>
            <Name>test TLS</Name>
             <OrderNumber__c></OrderNumber__c>
              <CurrentGenerators__c ></CurrentGenerators__c >
         </result>
      </IdDecryptResponse>
   </soapenv:Body>
</soapenv:Envelope>

My client wants the soap response is like above. How to achieve this using Custom wsdl. Please it's urgent i need help.
Thanks in advance.
Daniel BallingerDaniel Ballinger
It appears you are executing a dynamic SOQL query and returning the results, correct?

I suspect in this case you will need to iterate the dynamic results and explicitly set null values to the empty string. 

Can you share your Apex class that defines the webservice?