I have a Java-first web service, integrated with Spring. The service interface is simple:
@WebService
public interface ContactService {
public void addContact(@WebParam(name="contact") Contact contact);
public List<Contact> listContact();
public void removeContact(@WebParam(name="id") Integer id);
}
The implementation:
@WebService(endpointInterface = "com.foobar.contact.service.ContactService")
@Service
public class ContactServiceImpl implements ContactService {
// methods
}
The model:
@XmlAccessorType( XmlAccessType.FIELD )
public class Contact {
private Integer id;
private String firstname;
private String lastname;
private String email;
private String telephone;
}
If I use the Maven plugin cxf-java2ws-plugin
, the WSDL generated is correct. But without specifying the WSDL, the one CXF generates at runtime does not work.
For example, in the one generated by cxf-java2ws-plugin
, the return type is properly prefixed with tns
:
<xs:complexType name="listContactResponse">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="return" type="tns:contact"/>
</xs:sequence>
In the one generated at runtime, contact
is not prefixed, so it cannot be resolved:
<xsd:complexType name="listContactResponse">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="return" type="contact"/>
</xsd:sequence>
Both WSDLs do contain the proper complex type contact
.
How do I tell CXF/JAX-WS that contact
is the type it defined in the WSDL?