This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
We know that we can implement a service by implementing Provider<T> interface and by annotating the class with @WebserviceProvider. This approach would help us in dealing with raw XML. But while I was reading through Java webservices up and running by Martin Kalin, I came across the below statement from him about Restful WS
The @WebService annotation signals that the messages exchanged between the service and its clients will be SOAP envelopes. The @WebServiceProvider signals that the exchanged messages will be XML documents of some type, a notion captured in the phrase raw XML. Of course, a @WebServiceProvider could process and generate SOAP on its own, but this approach is not recommended. (A later example illustrates, however.) The obvious way to provide a SOAP-based web service is to use the annotation @WebService.
When @WebserviceProvider gives us the flexibility of handling at xml level, why would author feel that it is not a recommended approach for SOAP based webservice, but instead recommends for REST style WS.
Can anyone who read this book shed some light on this ?
Using the @WebServiceProvider annotation to develop SOAP web service endpoints will cause a lot of extra work for you.
When using @WebService, the whole SOAP part, as well as marshalling and unmarshalling of the payload, is taken care of for you by the web service stack.
If you use @WebServiceProvider, then you will have to implement the code that does this yourself.