• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between @WebService and @WebServiceProvider annotation?

 
Mahabub Ali Mohammad
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can anyone explain me the difference between annotating a java service with @WebService and @WebServiceProvider?

Thanks in Advance
-Mahabub Ali Mohammad.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
The annotation WebServiceProvider is used in endpoint classes implementing the javax.xml.ws.Provider<T> to associate the class with a <wsdl:service> element and a <wsdl:port> element in specified WSDL document. Such an endpoint works directly with (SOAP) messages or (SOAP) message payloads.
Note that the Provider<T> interface only has one single method, which in an implementing class will provide all the different messages received by the endpoint, while a class annotated with the WebService has one method for each kind of message the endpoint class can receive.
A class can either be annotated with the WebService or the WebServiceProvider annotation, but not both.
 
Mahabub Ali Mohammad
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Navi

Regards,
Mahabub Ali Mohammad.
 
anas alsarairah
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello

do you mean that the application server wont generate a WSDL file for web services annonated using @WebServiceProvider ?

thanks
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
anas alsarairah wrote:
do you mean that the application server wont generate a WSDL file for web services annonated using @WebServiceProvider ?

Correct - there is no way the application server knows what operations etc are supported by a web service annotated with @WebServiceProvider.
You may, however, supply an existing WSDL.
Best wishes!
 
Arnab Ban
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan Krizsan wrote:
Correct - there is no way the application server knows what operations etc are supported by a web service annotated with @WebServiceProvider.
You may, however, supply an existing WSDL.
Best wishes!


In another words, it is impossible to do bottom-up service development using @WebServiceProvider annotation? Please correct if wrong; if yes then how to consume the service?
 
K. Tsang
Bartender
Posts: 3348
12
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Ivan is it correct to say that @WebService annotation is for "SOAP" service and @WebServiceProvider annotation for "REST" service?

Or @WebServiceProvider service can also be for SOAP service?
 
Himai Minh
Ranch Hand
Posts: 1226
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@WebServiceProvider is used for XML based web services, not necessarily SOAP based web service.
With it, developers will need to parse the XML request or response using the XML parsers.
With it, no WSDL is generated. But with @WebService, a wsdl is generated.

If the service is annotated with @WebServiceProvider is implemented RESTfully (with Create, Update, Delete, Get methods), then it is a REST service.


Detail is given in Java Web Service Up and Running.
 
K. Tsang
Bartender
Posts: 3348
12
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Himai
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WebServiceProvider allows us to implement Web Services without Stub and WSDL.
WebServiceProvider are suitable for dynamically sending and recieving any SOAP message.
WebServiceProvider accepts an object marshalled by the JAX-WS engine as it is, and therefore for developing Web services , you must directly acquire values from XMLs that configure SOAP messages using APIs , and then assemble the XMLs.
 
Himai Minh
Ranch Hand
Posts: 1226
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more exam watch, you may need to use SAAJ API to create an XML request or Soap attachment when the web service is @WebServiceProvider.
You may see one question on this. You have to know SAAJ.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic