Forums Register Login

Regarding 'annotations' in webservice eg. @WebService

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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).
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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..
+Pie Number of slices to send: Send
 

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).
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
What is exact difference between JAX-RPC and JAX-WS?
+Pie Number of slices to send: Send
 

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


See this article for a high-level overview.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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..
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
 

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 ]
Curse your sudden but inevitable betrayal! And this tiny ad too!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2436 times.
Similar Threads
Invoking webservice from another webservice - Axis2
WebService and WebServiceClient Annotations
JAX-RPC client side programming
Writing webservices clients from wsdl files
How to expose wsdl to access our services
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:13:12.