• 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

Regarding 'annotations' in webservice eg. @WebService

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Currently i am working on web services in CXF framework.
And I have seen many web services with annotations.
I am bit confused with the use of annotations in web services.
For what i have read, I feel that these annotations are for the other tools, for examples to generate WSDL file from java class file or to create client stubs etc.

If i have web services and i am writing my client, so do I require these annotations in my web service?

Please correct me if something is not correct.

If possible please provide me any link which will describe it in deatil.

Thanks in advance.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The annotations are part of the JAX-WS API, and are used for implementing the service. If you're implementing the client then you needn't be concerned about them (in fact, you needn't even look at the source code of the service).
 
Rohit Kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please tell me how exactly annotations are "used for implementing the service" ?

How they distinguishes from a web service without annotations?

Again same Q. Is it ONLY useful for other tools to generate client stubs or wsdl etc?

Thanks in advance.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From a client perspective, there is no difference, because to a client it doesn't matter how a WS is implemented.

If you want to learn about JAX-WS, start at its home page: https://jax-ws.dev.java.net/ It points to articles, user guides etc.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The webservice "without using Annotations", are implemented using JAX-RPC.
There developer need to develop configuration file, run wscompile for WSDL & mapping, modify web.xml and implement webservices.xml (if not generating thru WSDL2Java). Also develop SEI. Although this all is simple but redundant for a webservice.

With JAX-WS "webervie using Annotations", you just need to give annotations in your implementation bean and deploy. Thats it!. All your deployment descriptors, WSDL etc will get automatically generated.

Please let me know if I answered your question..
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeffy Gupta:
The webservice "without using Annotations", are implemented using JAX-RPC.


Not necessarily. There are any number of WS APIs that don't use annotations (e.g. SAAJ).
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For an interesting example of using annotations to create a RESTful web service, take a look at the Jersey project. (an implementation of JSR-311)

Bill
 
Rohit Kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is exact difference between JAX-RPC and JAX-WS?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What is exact difference between JAX-RPC and JAX-WS?


See this article for a high-level overview.
 
Rohit Kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Annotations doesn't change the meaning of the semantics of the program, but they just tell to the other tools or libraries to process the element in special way.

Could any one tell me what exactly happends at background, when any toll or any framewrok enconters web service's annotations? (@WebService or handler etc)

Even any link to such article woud be helpful.

Thanks in advance.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See the annotations are not the mandatory to follow you can do it through xml configuration also. But annotation will help you as below:
1. no need to write xml files.
2. no need to write xtra coding or java files.
3. reduce code size
4. increase code clarity.
5. decrease development time
etc..
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

See the annotations are not the mandatory to follow you can do it through xml configuration also.


I don't think that's true for JAX-WS. Some deployment options may be specified external to the class via XML, but you can't do without the @WebService annotation at the very least.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Annotations doesn't change the meaning of the semantics of the program, but they just tell to the other tools or libraries to process the element in special way.


I guess we could argue what the "semantics of the program" are, but I'd say that statement is incorrect both generally, and specifically for JAX-WS.

As regards JAX-WS, if a regular POJO is annotated with @WebService, it suddenly gets exposed to whatever machine can get reach the host server (possibly the whole world). That has the potential to alter the characteristics of the code executing in that JVM dramatically.

More generally I could annotate a method with something that causes the method always to add 1 to the result it returns. That is a definite change in semantics. It's not just outside tools/frameworks that have access to annotations - code is free to inspect its own annotations. That goes with the trend to use annotations for domain-specific functionality (as opposed to code-specific functionality, which is what we are talking about here).
[ July 18, 2008: Message edited by: Ulf Dittmer ]
 
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic