• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Difference between @WebService and @WebServiceProvider annotation?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Navi

Regards,
Mahabub Ali Mohammad.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 2416
13
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Himai
 
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 2416
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic