JAX-WS规范实现了java类与soap之间“沟通”的桥梁。在这里有两点需要注意的,第一:开发者对这种“沟通”是一无所知的,是自动进行的;第二:这里我使用到的是“沟通”一词而不是“转换”。java类可以理解成实体,就好像使用移动电话的人,而soap是通讯手段,可以理解成电信运营商。java类只管发送或者接受消息,而soap负责如何将java类发出的消息转发到其他java类上。
JAX-WS规范是一组XML web services的JAVA API。JAX-WS允许开发者可以选择RPC-oriented或者message-oriented 来实现自己的web services。
在 JAX-WS中,一个远程调用可以转换为一个基于XML的协议例如SOAP。在使用JAX-WS过程中,开发者不需要编写任何生成和处理SOAP消息的代码。JAX-WS的运行时实现会将这些API的调用转换成为SOAP消息。
在服务器端,用户只需要通过Java语言定义远程调用所需要实现的接口SEI (service endpoint interface),并提供相关的实现,通过调用JAX-WS的服务发布接口就可以将其发布为WebService接口。
在客户端,用户可以通过JAX-WS的API创建一个代理(用本地对象来替代远程的服务)来实现对于远程服务器端的调用。
另外,JAX-WS规范到底有什么特点了?
可以参考以下的译文:(来源J2EE5新特性的)
Java API for XML-Based Web Services (JAX-WS)
Q. What is the difference between JAX-RPC and JAX-WS?
A. One of the main differences between JAX-RPC and JAX-WS is the programming model. A JAX-WS-based service uses annotations, such as@WebService
, to declare web service endpoints. Using these annotations obviates the need for deployment descriptors. With JAX-WS, you can have a web service deployed on a Java EE-compliant application server without a single deployment descriptor. JAX-WS also provides many additional features, such as asynchronous callback support. Refer to theJAX-WS specification for more information.
翻译:
JAX-RPC and JAX-WS的区别在于:
两者最主要的区别在编程模型。JAX-WS使用注释的办法,例如使用@WebService
标签
来声明服务端口。JAX-WS使用注释的办法避免为了部署应用而配置环境的麻烦。使用了JAX-WS,部署web service的时候,我们不需要每次都重新编写配置信息,只要是JAVA-EE所兼容的应用服务器都可以直接使用的。除此之外,JAX-WS还具有其他功能,例如异步的回调等。
Q. Does the Java EE 5 platform support JAX-WS?
A. Yes, the Java EE 5 platform supports JAX-WS-based services (in addition to JAX-RPC-based services) and makes these services portable throughJSR 109.
翻译:
Java EE 5 支持JAX-WS
Q. Can a JAX-WS-based service and a JAX-RPC-based service co-exist?
A. Yes.
翻译:
JAX-WS JAX-RPC 可以同时存在。
Q. How do I develop a simple JAX-WS-based service?
A. See this tip.
Q. Can a JAX-WS-based service that was developed and deployed on Java WSDP 2.0 be deployed and run on any Java EE 5-based platform?
A. No.
Q. Will a JAX-WS-based web service work with a JAX-RPC client and a JAX-RPC-based web service work with a JAX-WS client?
A. Yes.
翻译:
服务器端和客户端可以分别为JAX-WS或JAX-RPC
Q. Can I have a JAX-WS web service with deployment descriptors?
A. Yes. The same deployment descriptors, such as webservices.xml
,web.xml
, and ejb-jar.xml
, can be used, just as they were with JAX-RPC-based services. If a deployment descriptor is specified, the values specified in the annotation attributes will be overridden by the corresponding values specified in the deployment descriptors.
翻译:
在JAX-RPC-based services中可以使用配置文件,例如webservices.xml
, web.xml
和ejb-jar.xml
。一旦使用了配置文件,配置文件中的值就会覆盖(override
)注释中同样的变量的值。
Q. Can the deployment descriptor values be overridden?
A. No.
翻译:
配置文件中的值不会被覆盖(override)
Q. Do I have to specify all attributes for annotations?
A. No. Well-defined default values have been specified for all attributes of annotations.
翻译:
不需要指定注释中全部属性的值。因为这些值都默认预设好了。
最后,附上参考到两篇好文章:
基本了解:
http://jnn.iteye.com/blog/83103
JAX-WS或JAX-RPC的比较:
http://www.ibm.com/developerworks/cn/webservices/ws-tip-jaxwsrpc.html