使用JAX-WS开发一个服务端

JAX-WS服务开发指南
本文介绍使用JAX-WS开发服务的两种方法:从WSDL生成Java对象实现服务,或从Java对象开始并使用注解启用服务。讨论了从WSDL到Java的映射规则,并介绍了wsdl2java命令及@WebService和@SOAPBinding等关键注解。

Developing a Service using JAX-WS
You can develop a service using one of two approaches:

Start with a WSDL contract and generate Java objects to implement the service.
Start with a Java object and service enable it using annotations.

For new development the preferred path is to design your services in WSDL and then generate the code to implement them.
This approach enforces the concept that a service is an abstract entity that is implementation neutral.
It also means you can spend more time working out the exact interface your service requires before you start coding.

########################
wsdl <-> java mappings:
########################
wsdl:portType
The logical interface, defined by the wsdl:portType element, is mapped to a service endpoint interface (SEI).

wsdl:types
Any complex types defined in the WSDL are mapped into Java classes following the mapping defined by the Java Architecture for XML Binding (JAXB) specification.

wsdl:service
The endpoint defined by the wsdl:service element is also generated into a Java class that is used by consumers to access endpoints implementing the service.

##########################
wsdl2java commnand to generate service code
##########################
wsdl2java -ant -impl -server -d outputDir myService.wsdl


#####################
Properties of the @WebService annotation
#####################
name : default is to append PortType to the name of the implementation class.
targetNamespace : default is derived from the package name
serviceName : default is to use the name of the service's implementation class.
wsdlLocation : default is the URI at which the service is deployed.
endpointInterface : This property is only used when the attribute is used on a service implementation class.
portName : default is the append Port to the name of the service's implementation class.

#####################
The @SOAPBinding annotation
#####################
style Style.DOCUMENT (default)
Style.RPC
use Use.LITERAL (default)
Use.ENCODED
parameterStyle ParameterStyle.BARE
ParameterStyle.WRAPPED (default)

#####################
Other annotations
#####################
@WebMethod
@RequestWrapper
@ResponseWrapper
@WebFault
@Oneway
@WebParam
@WebResult

 

 

转载于:https://www.cnblogs.com/zjstar12/archive/2011/12/19/2293950.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值