Just for completion on this list.....

With 2.2.5 and 2.2.6, if you change the wrapper class to use getter/setter 
methods and annotate the getter instead of using a public field, it should 
work.   I've fixed the issues for using the field on trunk, but that won't 
make it until 2.2.7.

Also, the "name" in the wrapper @XmlElement should match the "name" in the 
@WebResult.    


Dan



On Thu January 14 2010 11:29:11 am [email protected] wrote:
> Hi,
> 
> thank your for your answer. I have tried your workarounf but it does not
> work. Here is my Interface:
> 
>         @WebMethod(action = "leseObligoKunde", operationName =
> "leseObligoKunde")
>         @ResponseWrapper(className="ObligoKontoListResponse")
>         public List<ObligoKonto> leseObligoKunde(KordobaCredentials creds,
>                         String kundennummer) throws KordobaException
> 
> 
> and this is my ResponseWrapper:
> 
> @XmlType(name = "ObligoKontoListResponse")
> public class ObligoKontoListResponse {
> 
>         @XmlElementWrapper(nillable = true, name = "return")
>         @XmlElement(name = "obligoKontoList")
>         public List<ObligoKonto> obligoKontoList;
> }
> 
> If I trace the response with tcpmon I can see that there is now an
> explicit return value:
> 
> HTTP/1.1 200 OK
> Server: Apache-Coyote/1.1
> Content-Type: text/xml;charset=UTF-8
> Content-Length: 309
> Date: Thu, 14 Jan 2010 16:14:42 GMT
> 
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/
> "><soap:Body><ns2:leseObligoKundeResponse xmlns:ns2="
> http://kordoba5/ObligoWebService/1/";><return xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance";
> xsi:nil="true"/></ns2:leseObligoKundeResponse></soap:Body></soap:Envelope>
> 
> But on the client I get again a NullPointerException:
> 
>         List<ObligoKonto> erg = obligoService.leseObligoKunde(creds,
> "0000186040");
>         System.out.println(erg.size());
> 
> 
> Then I made another test and removed the @ResponseWrapper Annotation of
> the Web Service on client side. Now my result contains one element, but
> with empty properties.
> 
> What I am doing wrong?
> 
> Thanks,
> Marc
> 
> 
> 
> 
> 
> 
> Von:
> Daniel Kulp <[email protected]>
> An:
> [email protected]
> Kopie:
> [email protected]
> Datum:
> 13.01.2010 16:53
> Betreff:
> Re: Returntype List: Empty List get null on client?
> 
> On Wed January 13 2010 4:51:17 am [email protected] wrote:
> > Hello,
> >
> > I have a problem with the return type of a web service function:
> >
> > public List<Customer> findCustomer(String name);
> >
> > If my service returns a empty list, the list get null on the client. Is
> > this a bug? Is there any workaround? Do I have to use Arrays instead of
> > Lists?
> 
> Not really a bug.   It's more due to how the spec maps the List into
> schema
> and thus the representation on the wire.   It would map that list to
> something
> like:
> 
> <element name="return"  type="tns:customer"
>       maxOccurs="unbounded" minOccurs="1"/>
> 
> Thus, if the list is empty or if the list is null, no "return" element is
> put
> on the wire at all.   On the receiving side, the runtime really has no
> indication of whether it should be an empty list or a null list.
> 
> I think the only way around it would be to create a new bean like:
> 
> @XmlType(name = "findCustomerResponse")
> public class FindCustomerResponse {
>     @XmlElementWrapper(nillable = true, name="return")
>     @XmlElement(name = "customers")
>     List<Customer> customers;
> 
>     ......getter/setters.....
> }
> 
> and then add an annotation to the method:
>  @ResponseWrapper(class = "......FindCustomerResponse")
>  public List<Customer> findCustomer(String name);
> 
> That changes the schema a bit to create a single "return" element that is
> nillable that then wrappers the "customer" elements.
> 

-- 
Daniel Kulp
[email protected]
http://www.dankulp.com/blog

Reply via email to