You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by kevin Wong <xn...@gmail.com> on 2007/07/10 23:26:37 UTC

unable to return null

Hi,
I am developing a WSDL first web service. There is a method, getNames which
return a List<String>. I would like to return null, but failed to do so.
What I got on the client side was an empty list. Is nillable = "true" in
XMLSchema work for a list ?? Please take a look at <s:element
name="getNamesResult"
nillable="true" type="s:string" maxOccurs="unbounded" minOccurs="0">.
Thanks.

<?xml version="1.0" encoding="utf-8"?>

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="
http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://avid.com/xena"
xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:http="
http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://my.com/FIG"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

  <wsdl:types>

    <s:schema elementFormDefault="qualified" targetNamespace="
http://my.com/FIG">

    <s:element name="getNames">

            <s:complexType>

                  <s:sequence>

                        <s:element name="handle" type="s:string" maxOccurs="1"
minOccurs="0"></s:element>

                  </s:sequence>

            </s:complexType>

      </s:element>

      <s:element name="getNamesResponse">

            <s:complexType>

                  <s:sequence>

                        <s:element name="getNamesResult" nillable="true"
type="s:string" maxOccurs="unbounded" minOccurs="0">

                        </s:element>

                  </s:sequence>

            </s:complexType>

      </s:element>

    </s:schema>

  </wsdl:types>





  <wsdl:message name="getNamesRequest">

      <wsdl:part name="parameters" element="tns:getNames"></wsdl:part>

  </wsdl:message>

  <wsdl:message name="getNamesResponse">

      <wsdl:part name="parameters" element="tns:getNamesResponse"></
wsdl:part>

  </wsdl:message>





  <wsdl:portType name="ServerSoap">

    <wsdl:operation name="getNames">

      <wsdl:input message="tns:getNamesRequest"></wsdl:input>

      <wsdl:output message="tns:getNamesResponse"></wsdl:output>

    </wsdl:operation>

  </wsdl:portType>





  <wsdl:binding name="ServerSoap" type="tns:ServerSoap">

    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />

    <wsdl:operation name="getNames">

      <soap:operation soapAction="http://my.com/FIG/getNames" style="document"
/>

      <wsdl:input>

        <soap:body use="literal" />

      </wsdl:input>

      <wsdl:output>

        <soap:body use="literal" />

      </wsdl:output>

    </wsdl:operation>

  </wsdl:binding>



  <wsdl:service name="Server">

    <wsdl:port name="ServerSoap" binding="tns:ServerSoap">

      <soap:address location="http://localhost:8080/fig/FIG" />

    </wsdl:port>

  </wsdl:service>

</wsdl:definitions>

Re: unable to return null

Posted by Daniel Kulp <dk...@apache.org>.
Kevin,

That schema would allow the returned list to contain null's, not that the 
list could be null.

Unfortunately, I'm not really thinking of any way that would work short 
of creating a "wrapper" type to hold the list.  

<s:complexType name="stringArray">
    <s:sequence>
        <s:element name="item" type="s:string" 
              minOccurs="0" maxOccurs="unbounded"/>
    </s:sequence>
</s:complexType>

.....
    <s:element name="getNamesResult"
          nillable="true" type="stringArray"/>
....

Probably not what you want though.

Dan


On Tuesday 10 July 2007 17:26, kevin Wong wrote:
> Hi,
> I am developing a WSDL first web service. There is a method, getNames
> which return a List<String>. I would like to return null, but failed
> to do so. What I got on the client side was an empty list. Is nillable
> = "true" in XMLSchema work for a list ?? Please take a look at
> <s:element name="getNamesResult"
> nillable="true" type="s:string" maxOccurs="unbounded" minOccurs="0">.
> Thanks.
>
> <?xml version="1.0" encoding="utf-8"?>
>
> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="
> http://schemas.xmlsoap.org/wsdl/mime/"
> xmlns:tns="http://avid.com/xena"
> xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:http="
> http://schemas.xmlsoap.org/wsdl/http/"
> targetNamespace="http://my.com/FIG"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
>
>   <wsdl:types>
>
>     <s:schema elementFormDefault="qualified" targetNamespace="
> http://my.com/FIG">
>
>     <s:element name="getNames">
>
>             <s:complexType>
>
>                   <s:sequence>
>
>                         <s:element name="handle" type="s:string"
> maxOccurs="1" minOccurs="0"></s:element>
>
>                   </s:sequence>
>
>             </s:complexType>
>
>       </s:element>
>
>       <s:element name="getNamesResponse">
>
>             <s:complexType>
>
>                   <s:sequence>
>
>                         <s:element name="getNamesResult"
> nillable="true" type="s:string" maxOccurs="unbounded" minOccurs="0">
>
>                         </s:element>
>
>                   </s:sequence>
>
>             </s:complexType>
>
>       </s:element>
>
>     </s:schema>
>
>   </wsdl:types>
>
>
>
>
>
>   <wsdl:message name="getNamesRequest">
>
>       <wsdl:part name="parameters" element="tns:getNames"></wsdl:part>
>
>   </wsdl:message>
>
>   <wsdl:message name="getNamesResponse">
>
>       <wsdl:part name="parameters" element="tns:getNamesResponse"></
> wsdl:part>
>
>   </wsdl:message>
>
>
>
>
>
>   <wsdl:portType name="ServerSoap">
>
>     <wsdl:operation name="getNames">
>
>       <wsdl:input message="tns:getNamesRequest"></wsdl:input>
>
>       <wsdl:output message="tns:getNamesResponse"></wsdl:output>
>
>     </wsdl:operation>
>
>   </wsdl:portType>
>
>
>
>
>
>   <wsdl:binding name="ServerSoap" type="tns:ServerSoap">
>
>     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
>
>     <wsdl:operation name="getNames">
>
>       <soap:operation soapAction="http://my.com/FIG/getNames"
> style="document" />
>
>       <wsdl:input>
>
>         <soap:body use="literal" />
>
>       </wsdl:input>
>
>       <wsdl:output>
>
>         <soap:body use="literal" />
>
>       </wsdl:output>
>
>     </wsdl:operation>
>
>   </wsdl:binding>
>
>
>
>   <wsdl:service name="Server">
>
>     <wsdl:port name="ServerSoap" binding="tns:ServerSoap">
>
>       <soap:address location="http://localhost:8080/fig/FIG" />
>
>     </wsdl:port>
>
>   </wsdl:service>
>
> </wsdl:definitions>

-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog