SOAP XML – A different way to pass nil

I have been working on some standard Oracle ERP Cloud SOAP payloads and found something different.

Suppose you want to update the End Date field on the Trading Partner Item, you can simply send the below request to set the date.

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/&quot;
xmlns:typ="http://xmlns.oracle.com/apps/scm/productModel/items/tradingPartnerItems/tradingPartnerItemServiceV2/types/&quot;
xmlns:trad="http://xmlns.oracle.com/apps/scm/productModel/items/tradingPartnerItems/tradingPartnerItemServiceV2/&quot; >
<soapenv:Header/>
<soapenv:Body>
<typ:updateTradingPartnerItem>
<typ:tradingPartnerItem>
<trad:TradingPartnerItemId>300000063693002</trad:TradingPartnerItemId>
<trad:EndDate>2019-09-21</trad:EndDate>
</typ:tradingPartnerItem>
</typ:updateTradingPartnerItem>
</soapenv:Body>
</soapenv:Envelope>

However what if you want to make the field update to no value or null value, or simply blank, however you want to put it.

In that scenario, you cannot simply use any of the below forms of the XML Attributes.

<!-- 1. --> <trad:EndDate>NULL</trad:EndDate>
<!-- 2. --> <trad:EndDate>nil</trad:EndDate>
<!-- 3. --> <trad:EndDate></trad:EndDate>

The only way in which you can achieve the operation i.e. setting the attribute to no value in the database is, if you pass it in the below format.

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/&quot;
xmlns:typ="http://xmlns.oracle.com/apps/scm/productModel/items/tradingPartnerItems/tradingPartnerItemServiceV2/types/&quot;
xmlns:trad="http://xmlns.oracle.com/apps/scm/productModel/items/tradingPartnerItems/tradingPartnerItemServiceV2/&quot;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
<soapenv:Header/>
<soapenv:Body>
<typ:updateTradingPartnerItem>
<typ:tradingPartnerItem>
<trad:TradingPartnerItemId>300000063693002</trad:TradingPartnerItemId>
<trad:EndDate xsi:nil="true" />
</typ:tradingPartnerItem>
</typ:updateTradingPartnerItem>
</soapenv:Body>
</soapenv:Envelope>

A different namespace is also required for setting the xsi:nil=”true”. Make sure you include that in your request.