axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JOVANOVIC Nenad <Nenad.JOVANO...@svc.co.at>
Subject [Axis2] SOAP responses for empty lists
Date Thu, 27 Jan 2011 10:37:04 GMT
Hi all,

given the following web service method implementation:

  public String[] getString() {
    return null;
  }

with the following response element definition from the WSDL (used by WSDL2Java):

            <xs:element name="getStringResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true"
type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>

the resulting SOAP response looks like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <ns2:getStringResponse xmlns:ns2="http://experiment.com">
         <ns2:return xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
      </ns2:getStringResponse>
   </soapenv:Body>
</soapenv:Envelope>

However, I would have expected the "return" element to be missing altogether. The above SOAP
response tells the client that "the return value of this method is a one-element String list
containing null", rather than "a null / empty list". 

The same effect occurs when the String list is not (as above) directly returned in the method's
signature, but inside some container, such as:

  public Container getContainer() {
    Container c = new Container();
    c.setMyStringArray(null);
    return c;
  }

But here, if the line "c.setMyStringArray(null)" is commented out (i.e., no explicit initialization
to null), the result is

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <ns2:getContainerResponse xmlns:ns2="http://experiment.com">
         <ns2:return/>
      </ns2:getContainerResponse>
   </soapenv:Body>
</soapenv:Envelope>

The meaning of this SOAP response is "a one-element String list containing the empty String",
which is not expected either.

Moreover, if I change the WSDL definition to nillable="false" and return a one-element String
array with null ("new String[] {null}"), I get

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <ns2:getStringResponse xmlns:ns2="http://experiment.com"/>
   </soapenv:Body>
</soapenv:Envelope>

in the non-container case, meaning "null / empty list". In the container case, I get

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <ns2:getContainerResponse xmlns:ns2="http://experiment.com">
         <ns2:return/>
      </ns2:getContainerResponse>
   </soapenv:Body>
</soapenv:Envelope>

regardless of the initialization type (explicit/implicit), meaning "a one-element String list
with an empty String".

Am I getting something wrong, or are these candidates for a JIRA issue?

Thanks,
Nenad Jovanovic


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Mime
View raw message