rayss
rayss

Reputation: 657

xsi:nil="true" in soap request

I have xsi:nil="true" in my soap request. What does mean? How can I pass value on that?

Any help is appreciated

Upvotes: 4

Views: 6248

Answers (2)

Kiran Chaudhary
Kiran Chaudhary

Reputation: 144

To remove it set the value in Soap::Data object to arrayref instead of undef. say you have Field1 as your key then the Soap Data object would look like :

*bless( {
     '_name' => 'Field1',
     '_signature' => [],
     **'_value' => [
                   undef
                 ],**
     '_prefix' => 'm',
     '_attr' => {
                  'id' => '1219615'
                }
 }, 'SOAP::Data' )*

and the resulting xml would be : < m:Field1 xsi:nil=true id="1219615" /> now if you change the object to :

*bless( {
     '_name' => 'Field1',
     '_signature' => [],
     **'_value' => [],**
     '_prefix' => 'm',
     '_attr' => {
                  'id' => '1219615'
                }
}, 'SOAP::Data' )*

You will get the desired output < m:Field1 id="1219615" />. The solution is in perl.

Upvotes: 2

Brian Driscoll
Brian Driscoll

Reputation: 19635

The nillable attribute indicates that the element that the attribute is on is present but has no value, similar to NULL in most programming languages.

If you want to assign a value to the element you can do so, however you'll have to remove the xsi:nil attribute first, otherwise you'll get an error.

Upvotes: 3

Related Questions