I've used JAX-WS before, but have not passed a custom object as a parameter before. I'm using GlassFish 3.1, NetBeans 7.3 and created services through NetBeans JAX-WS wizard. My problem is when custom object (Criteria) passed to service is received as null on the server. I can pass default types like int successfully.
@WebService(serviceName = "ECLService")
@Stateless()
public class ECLService {
    @EJB
    PersistenceImpl persistence;
    @WebMethod(operationName = "listRevisions")
    public List<Revision> listRevisions(@WebParam(name="criteria")Criteria criteria) {
        System.out.println("criteria is "+(criteria ==null ? "null":" not null"));
        List<Revision> revisions = persistence.getRevisions(criteria);
        return revisions;
    }
}
Criteria.java
@XmlRootElement
public class Criteria implements Serializable {
    private static final long serialVersionUID = 1L;
    public static final String LIST_TYPE = "criteria.key.listtype";
    public static final String TYPE_ALL = "criteria.value.all";
    public static final String TYPE_ERROR = "criteria.value.error";
    public static final String TYPE_ARCHIVE = "criteria.value.archive";
    public static final String TYPE_APPROVAL = "criteria.value.approval";
    private Map<String, String> parameters;
    public Map<String, String> getParameters() {
        return parameters;
    }
    public String getParameter(String key) {
        if (parameters==null || key==null) {
            return null;
        } else {
            return parameters.get(key);
        }
    }
    public void setParameters(Map<String, String> parameters) {
        this.parameters = parameters;
    }
    public void setParameter(String key, String value) {        
        if (parameters==null) {
            parameters = new HashMap<String,String>();
        }        
        parameters.put(key, value);
    }
    public void setType(String type) {
        setParameter(LIST_TYPE, type);
    }
    public String getType() {
        return getParameter(LIST_TYPE);
    }
    @Override
    public int hashCode() {
        int hash = 7;
        hash = 43 * hash + (this.parameters != null ? this.parameters.hashCode() : 0);
        return hash;
    }
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Criteria other = (Criteria) obj;
        if (this.parameters != other.parameters && (this.parameters == null || !this.parameters.equals(other.parameters))) {
            return false;
        }
        return true;
    }
}
Is there anything I'm missing like annotation or something?
Message sent looked like this:
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body><ns2:listRevisions xmlns:ns2="http://webservice.ecl.abc.com/"><ns2:criteria>
<type>TYPE_ALL</type></ns2:criteria></ns2:listRevisions></S:Body></S:Envelope>
HTTP/1.1 200 OK
server: grizzly/1.9.50
Content-Type: text/xml;charset=utf-8
 Transfer-Encoding: chunked
Date: Fri, 17 May 2013 07:37:15 GMT
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body>
<ns2:listRevisionsResponse xmlns:ns2="http://webservice.ecl.abc.com/"/></S:Body> 
</S:Envelope>
                Try adding targetNamespace to WebParam annotation, with the namespace of the schema.
I faced the same issue. The root element was defaulted to the service namespace instead of schema namespace. I added targetNamespace to WebParam and that helped resolve this issue.
@WebResult(name="status")
public String send(@WebParam(name="event",targetNamespace="http://efw/event/schema") EventType event);
                        @XmlAccessorType(XmlAccessType.FIELD) at the class level - JAXB would look at fields, not methods. If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With