# How to set a SOAP object to nil

**URL:** <https://www.ruby-forum.com/t/how-to-set-a-soap-object-to-nil/123121>\
**Category:** Ruby\
**Created:** [December 14, 2007, 6:52am UTC](https://www.ruby-forum.com/t/how-to-set-a-soap-object-to-nil/123121 "2007-12-14T06:52:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevev](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b3f665/32.png) [@stevev](https://www.ruby-forum.com/u/stevev)\
**Post date:** [December 14, 2007, 6:52am UTC](https://www.ruby-forum.com/t/how-to-set-a-soap-object-to-nil/123121/1 "2007-12-14T06:52:46Z")

</div>

Hi,

we are using SOAP::WSDLDriverFactory and creating an rpc driver based on  
a WSDL file.

We have a complex type that we want to be able to set to nil or null in  
the soap request.

In order to make this more dynamic we create a object whose instance  
variable map to one of the elements in the WSDL file.

So say there is a complex type of Accountant within another complex type  
of Applicant and Accountant has a number of different fields.

(NOTE: Example below has been cut down to give you the basic idea)

\<xsd:complexType name=“ApplicantTO”\>  
xsd:sequence  
\<xsd:element minOccurs=“0” name=“accountant” nillable=“true”  
type=“ns1:AccountantTO” /\>

\</xsd:complexType\>

\<xsd:complexType name=“AccountantTO”\>  
xsd:sequence  
\<xsd:element minOccurs=“0” name=“accountantFigures”  
nillable=“true” type=“xsd:int” /\>  
\<xsd:element minOccurs=“0” name=“company” nillable=“true”  
type=“xsd:string” /\>  
\<xsd:element minOccurs=“0” name=“name” nillable=“true”  
type=“xsd:string” /\>  
\</xsd:sequence\>  
\</xsd:complexType\>

\<xsd:schema xmlns:xsd=“[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)”  
attributeFormDefault=“qualified” elementFormDefault=“qualified”  
targetNamespace=“myURL”\>  
\<xsd:element name=“submitPreapproval”\>  
xsd:complexType  
xsd:sequence  
\<xsd:element maxOccurs=“1” minOccurs=“1” name=“in0”  
nillable=“true” type=“ns1:ApplicantTO” /\>  
\</xsd:sequence\>

```
</xsd:complexType>

```

\</xsd:element\>  
\<xsd:element name=“submitPreapprovalResponse”\>  
xsd:complexType  
xsd:sequence  
\<xsd:element maxOccurs=“1” minOccurs=“1” name=“out”  
nillable=“true” type=“xsd:int” /\>  
\</xsd:sequence\>  
\</xsd:complexType\>  
\</xsd:element\>  
\</xsd:schema\>

so if I have object 1 with in0 set as an instance variable

object 1  
@in0 = object 2

and object 2 with no instance variables set (so no accountant set)

object 2

when I call rpc\_driver.submitPreapproval(object 1) I would expect that  
the soap request has accountant set to null.

Instead I find that it has an accountant complextype with blank strings  
for all it’s fields.

Is there something I need to know to make sure accountant is sent down  
the line as null?

Any help would be appreciated

Steve

---

<div class="post-metadata">

**Author:** ![stevev](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b3f665/32.png) [@stevev](https://www.ruby-forum.com/u/stevev)\
**Post date:** [May 15, 2009, 4:30pm UTC](https://www.ruby-forum.com/t/how-to-set-a-soap-object-to-nil/123121/2 "2009-05-15T16:30:25Z")

</div>

Did you find a solution to this one? I’m experiencing exactly the same  
error.
