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

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

 

 

posted @ 2011-12-19 22:31  万法自然~  阅读(241)  评论(0编辑  收藏  举报