`
wanxiaotao12
  • 浏览: 456377 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

JAX-WS规范

 
阅读更多

概念

 

RPC(Remote Procedure Call Protocol)——远程过程调用协议,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议。

 

JAX-WS规范是一组XML web servicesJAVA APIJAX-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-WSAPI创建一个代理(用本地对象来替代远程的服务)来实现对于远程服务器端的调用。

通过web service所提供的互操作环境,我们可以用JAX-WS轻松实现JAVA平台与其他编程环境(.net)的互操作。

JAX-WS annotation

 主要常用接口:

Oneway 

只有输入值,无返回值

WebMethod

对方法进行注解

WebParam

对输入参数进行注解

WebResult

对返回数据进行注解

WebService

注解一个web服务

@WebService,必选的标注。用于导出的服务接口及其实现类

name

定义导出的服务接口的名字,对应于WSDL文档中wsdl:portType。默认是服务接口的Java类名加PortType

targetNamespace

定义导出的服务接口的名域(namespace),默认是倒置的服务接口Java包名。如demo.cxf.UserService的名域将会是http://cxf.demo/

serviceName

定义服务名,与名域一起唯一标识一个服务。默认是其Java类名

wsdlLocation

WSDL文档URL。可由服务器容器自动产生

endpointInterface

指定服务接口的Java类。通常用于服务实现类的标注。应当指定类的全名,如demo.cxf.UserService

portName

对应WSDL文档中的wsdl:port元素。默认是Java类名加Port

@WebMethod,可选的标注,用于服务接口的方法

operationName

指定方法在WSDL文档中的名字,客房端用此名字调用方法

action

Specifies the value of the soapAction attribute of the soap:operation element generated for the method. The default value is an empty string.

exclude

生成WSDL文档时将该方法排除在外

@SOAPBinding,可选的标注,用于指定生成的SOAP定义文档风格。关于此标注再详细的信息请查阅SOAP标准等参考资料

style

Style.DOCUMENT (默认)

Style.RPC

SOAP消息风格

use

Use.LITERAL (默认)

Use.ENCODED

SOAP数据编码方式

parameterStyle

ParameterStyle.BARE

ParameterStyle.WRAPPED (默认)

Specifies how the method parameters, which correspond to message parts in a WSDL contract, are placed into the SOAP message body. A parameter style of BARE means that each parameter is placed into the message body as a child element of the message root. A parameter style of WRAPPED means that all of the input parameters are wrapped into a single element on a request message and that all of the output parameters are wrapped into a single element in the response message. If you set the style to RPC you must use the WRAPPED parameter style.

@RequestWrapper,可选的标注,用于指定如何包装客户端调用服务方法使用的参数

@ResponseWrapper,可选的标注,用于指定如何包装客户端调用服务方法的返回值

@WebFault,可选的标注,用于注解服务接口方法抛出的异常

name

异常的名字

targetNamespace

对应的名域,默认是服务接口的名域

faultName

实现该异类的类名

@WebParam,可选的标注,用于指定方法参数的使用方式

name

WSDL文档中的名字,默认是arg0,arg1…

targetNamespace

对应的名域。默认是服务接口的名域

mode

Mode.IN (默认)Mode.OUTMode.INOUT

对于Java程序没有意义

header

true或者false(默认),指定该参数是否在SOAP消息头部发送

partName

Specifies the value of the name attribute of the wsdl:part element for the parameter when the binding is document.

@WebResult,可选的标注,用于指定返回值的使用方式

name

返回值在WSDL文件中的名字。默认是return

targetNamespace

对应的名域。默认是服务接口的名域

header

true或者false(默认),指定该参数是否在SOAP消息头部发送

partName

Specifies the value of the name attribute of the wsdl:part element for the parameter when the binding is document.

 

具体请参考j2EE API是如下两个包:

²  javax.jws

²  javax.jws.soap

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics