JAXB generally doesn't like interfaces too much. In general, we definitely suggest using concrete classes.
That said, one major issue is that your interface doesn't have setter methods on it. There's no way there's any chance of it working without that. JAXB would only expose properties that have bother getters and setters. That said, I still doubt it will work as interfaces. The jaxws spec really doesn't allow for that at all. Just concrete data objects. Dan On Friday 25 January 2008, Phil Weighill-Smith wrote: > For some reason I can't get CXF 2.0.3 to generate what looks like > correct WSDL from a set of Java interfaces. I either get no XML > representing the object(s) or get an abstract complex type for the > object(s) depending on the interfaces involved. > > Here's a simple example. Because I use interfaces for the returned > object(s) I have a factory. This looks like: > > package org.bad; > > /** > * A simple factory to allow JAXB to handle the various interfaces > used. */ > public class SimpleFactory { > /** > * Support the [EMAIL PROTECTED] SimpleThing} class. > * > * @return a SimpleThing implementation. Added setters for good > luck not * knowing just how JAXB should handle unmarshalling > */ > public SimpleThing createSimpleThing() { > return new SimpleThing() { > /** > * The description. > */ > private String description = null; > > /** > * The name. > */ > private String name = null; > > @Override > public String getDescription() { > return description; > } > > @Override > public String getName() { > return name; > } > > /** > * Allow the description to be modified. > * > * @param description the new description > */ > public void setDescription(String description) { > this.description = description; > } > > /** > * Allow the name to be modified. > * > * @param name the new name > */ > public void setName(String name) { > this.name = name; > } > }; > } > } > > I then have the SimpleThing (the object to be returned) defined as: > > package org.bad; > > import javax.xml.bind.annotation.XmlType; > > /** > * A simple thing to communicate over the web service. > */ > @XmlType(factoryClass = SimpleFactory.class, > factoryMethod = "createSimpleThing") > public interface SimpleThing { > /** > * A read-only name property. > * > * @return the name property > */ > String getName(); > > /** > * A read-only description property. > * > * @return the description property > */ > String getDescription(); > } > > Finally, the service is then defined thus: > > package org.bad; > > import javax.jws.WebService; > import javax.jws.WebParam; > import javax.jws.WebResult; > import javax.jws.soap.SOAPBinding; > > /** > * The SEI java class. > */ > @WebService(name = "SimpleService", > targetNamespace = "http://org.bad.SimpleService/service") > @SOAPBinding(style = SOAPBinding.Style.RPC, > use = SOAPBinding.Use.ENCODED, > parameterStyle = SOAPBinding.ParameterStyle.WRAPPED) > public interface SimpleService { > /** > * Get a [EMAIL PROTECTED] SimpleThing} by name. > * > * @param name the name for the [EMAIL PROTECTED] SimpleThing} to be > returned. * @return the [EMAIL PROTECTED] SimpleThing} with that name, or > null if > there isn't a > * match > */ > @WebResult(name = "result", > targetNamespace = "http://org.bad.SimpleService") > SimpleThing getThing( > @WebParam(name = "name") > final String name); > } > > When I run the java2wsdl (via the IDEA's Web Services integration > mechanism) I get the following output: > > <?xml version="1.0" encoding="UTF-8"?> > <wsdl:definitions name="SimpleServiceService" > targetNamespace="http://org.bad" > xmlns:ns1="http://org.bad.SimpleService/service" > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" > xmlns:tns="http://org.bad" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> > <wsdl:message name="getThing"> > <wsdl:part name="name" type="xsd:string"> > </wsdl:part> > </wsdl:message> > <wsdl:message name="getThingResponse"> > <wsdl:part name="result"> > </wsdl:part> > </wsdl:message> > <wsdl:portType name="SimpleService"> > <wsdl:operation name="getThing"> > <wsdl:input name="getThing" message="ns1:getThing"> > </wsdl:input> > <wsdl:output name="getThingResponse" > message="ns1:getThingResponse"> > </wsdl:output> > </wsdl:operation> > </wsdl:portType> > <wsdl:binding name="SimpleServiceServiceSoapBinding" > type="ns1:SimpleService"> > <soap:binding style="rpc" > > transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation > name="getThing"> > <soap:operation soapAction="" style="rpc"/> > <wsdl:input name="getThing"> > <soap:body use="literal" > > namespace="http://org.bad.SimpleService/service"/> > </wsdl:input> > <wsdl:output name="getThingResponse"> > <soap:body use="literal" > > namespace="http://org.bad.SimpleService/service"/> > </wsdl:output> > </wsdl:operation> > </wsdl:binding> > <wsdl:service name="SimpleServiceService"> > <wsdl:port name="SimpleServicePort" > binding="ns1:SimpleServiceServiceSoapBinding"> > <soap:address location="http://localhost:9090/hello"/> > </wsdl:port> > </wsdl:service> > </wsdl:definitions> > > > As you can see, there is no XML binding schema for SimpleThing and > nothing in the result from the getThing operation (in bold)... what > have I done wrong? > > Note that I found I could not use use the default binding style > (document) and use (literal) with wrapped or bare parameter styles > since these threw exceptions (either that the wrapper classes were > missing from the class path or with an NPE from the generator code > somewhere). > > Phil -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog