On Thursday, March 08, 2012 11:19:45 AM Marc SCHNEIDER wrote:
> Hello,
> 
> I have an interface containing the declaration of this method :
> 
> @WebMethod(operationName = "foo")
> public long[] foo(String params[]);
> 
> Right now if I call this method with 'param' containing null values
> they are ignored and only non null values are taken in account. How
> can I get null values? I heard of using 'nillable' within the
> 'XmlElement' annotation but it doesn't work for me.

This isn't really an easy thing to do with java6 unless you endorse the 2.2 
version of the jaxb-api jar.   If you do that, you can add the @XmlElement 
annotation on to the param with the nillable flag (and the required flag).

If you need to stick to jaxb/jaxws 2.1, you would need to create a request 
wrapper object:

    @WebMethod
    @RequestWrapper(className = "com.blah.FooRequestWrapper")
    public long[] foo(String params[]);


    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "FooRequest", propOrder = { "params" })
    public static class FooRequest {
        @XmlElement(name = "params", required = true, nillable = true)
        protected String params[];
        public String[] getParams() {
            return params;
        }
        public void setInput(String[] params) {
            this.params = params;
        }
    }


That should work.

Dan

 


> 
> Thanks in advance, Marc.
-- 
Daniel Kulp
dk...@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to