My Requirement is to have an element as optional in a Soap Message if it does not have any value.That the element should not appear in the SOAP Message.I have used minOccurs="0" for each element but still it is not working.Please suggest me a way to do this.
In Axis 1.x this is accomplished with a handler.
Custom Deployment - Introducing WSDD: More deployment - Handlers and Chains
Supraja Kannaiyan wrote:My Requirement is to have an element as optional in a Soap Message if it does not have any value.
As far as I'm aware, there is no way to do that. minOccurs=0 simply permits that a non-existent (null?) value may be represented with the absence of the element. However this does not disallow empty values, e.g. <tns:myElement /> or <tns:myElement></tns:myElement>. Also often a non-existent (null) value is represented with the xsi:nil attribute, e.g. <tns:myElement xsi:nil="true" /> which tends to be preferred by code generation tools because it is explicit in its intent.
But in general, the absence of an element does not have any particular meaning: It may indicate that the information is unknown, or not applicable, or the element may be absent for some other reason. Sometimes it is desirable to represent an unshipped item, unknown information, or inapplicable information explicitly with an element, rather than by an absent element. For example, it may be desirable to represent a "null" value being sent to or from a relational database with an element that is present.
So often if you wish to omit the "optional","non-existent" element you'll have to suppress it yourself (by removing it).
Also understand that <tns:myElement xsi:nil="true" /> has a different meaning than <tns:myElement />
just like String myText = null; and String myText = ""; are different.