Search code examples
web-servicessoapxsdwsdljax-ws

Java Web Service using annotation


I am developing SOAP web service using annotation i.e. @WebService, @WebMethod and XML annotation for request and response entities. The web server generates the WSDL contract which the client uses. I am not able to set any xml restriction on the response elements, say for example i want top set a String element to max length to 50 characters. As I am not writing the WSDL/XSD manually is there a way to define this through annotation so the the server includes in the generated WSDL.


Solution

  • JAX-WS web service uses JAXB for data binding. Unfortunately, the default JAXB reference implementation does not support JAXB facet. So with the default implementation, you cannot use annotation to specify string element maxlength restriction. However, you can check out JAXB-Facets project, which does exactly what you want.