| Author |
Problem with empty elements is SOAP message
|
Andrey Karachoun
Greenhorn
Joined: Jan 14, 2003
Posts: 7
|
|
Hi all, I have WSDL file and need to develop a client that sends SOAP request with some required and optional elements. I use WSDL2Java tool from Axis to generate client stubs from WSDL. In WSDL optional elements are marked by attribute minOccurs in the following way: <xsd:element name="quantityRequested" type="tns:Individuals" minOccurs="0"/> In my client I don't fill this optional element with any value. So when client generates SOAP message this empty element is described like this: ... <quantityRequested xsi:type="xsd:long" xsi:nil="true"/> ... The server processes request and when parsing this element it throws NumberFormatException because this element is empty. So I make a conclusion that the server does not expect any optional empty elements in messages, instead it prefers the message not to contain such elements at all. My question is: how should I handle this and what is the best way to make client generate SOAP messages w/out empty optional elements? Thanks, Andrey
|
 |
Andrey Karachoun
Greenhorn
Joined: Jan 14, 2003
Posts: 7
|
|
Hi, Unfortunately in current Axis release (Axis 1.2 RC2) this problem can not be resolved in any configuraton way, so I just had to patch two Axis source files: SerializationContext and RPCParam. org.apache.axis.encoding.SerializationContext old way: 134: /** 135: * Send an element with an xsi:nil="true" attribute for null 136: * variables (if Boolean.TRUE), or nothing (if Boolean.FALSE). 137: */ 138: private Boolean sendNull = Boolean.TRUE; new way: 134: /** 135: * Send an element with an xsi:nil="true" attribute for null 136: * variables (if Boolean.TRUE), or nothing (if Boolean.FALSE). 137: */ 138: private Boolean sendNull = Boolean.FALSE; org.apache.axis.message.RPCParam old way: 177: context.serialize(getQName(), // element qname 178: null, // no extra attrs 179: value, // value 180: xmlType, // java/xml type 181: Boolean.TRUE, wantXSIType); new way: 177: context.serialize(getQName(), // element qname 178: null, // no extra attrs 179: value, // value 180: xmlType, // java/xml type 181: Boolean.FALSE, wantXSIType); Regards, Andrey
|
 |
 |
|
|
subject: Problem with empty elements is SOAP message
|
|
|