JAX-WS学习(四)、基本Annotation定义

1、@javax.jws.WebService(使用@WebService来标记一个类或接口,表示这是一个WebService服务),其中的属性:

Property Description Default

name

The name of the wsdl:portType(wsdl文件中<portType name="...">的值)

The unqualified name of the Java class or interface(默认是这个接口或类的名字)

targetNamespace

The XML namespace of the the WSDL and some of the XML elements generated from this web service. Most of the XML elements will be in the namespace according to the JAXB mapping rules.(wsdl文件的命名空间)

The namespace mapped from the package name containing the web service according to section 3.2 of the JAX-WS 2.0 specification.(默认是包名反转)

serviceName

The Service name of the web service: wsdl:service(wsdl文件中<service name="...">的值)

The unqualified name of the Java class or interface + "Service"(默认是类名或接口名+”Service“)

endpointInterface

The qualified name of the service endpoint interface. If the implementation bean references a service endpoint interface, that service endpoint interface is used to determine the abstract WSDL contract (portType and bindings). In this case, the service implementation bean MUST NOT include any JSR 181 annotations other than @WebService and @HandlerChainIn addition, the @WebService annotation MUST NOT include the name annotation element. The endpoint implementation class is not required to implement the endpointInterface.(里面写上所实现的接口,当前实现类并不需要实现implements这个接口)

None – If not specified, the endpoint implementation class is used to generate the web service contract. In this case, a service endpoint interface is not required.(默认为空,如果没指定实现接口,则直接把当前类当做服务类,这种情况下,服务端接口就不需要了)

portName

The wsdl:portName(wsdl文件中<port name="...">的值)

The WebService.name + "Port"(默认是这个服务的name值+"Port“)

wsdlLocation

Not currently used by JAX-WS RI 2.2.7

 

2、@javax.jws.WebMethod(使用@WebMethod来暴露出WebService中的方法),其中的属性:

Property Description Default

operationName

The name of the wsdl:operation matching this method. For operations using the mode defined bySOAPBinding.Style.DOCUMENTSOAPBinding.Use.LITERAL, and SOAPBinding.ParameterStyle.BARE, this name is also used for the global XML element representing the operations body element. The namespace of this name is taken from the value @WebService.targetNamespace or its default value.(<portType>子标签中的<operation name="....">值)

The name of the Java method(默认是方法名)

action

The XML namespace of the the WSDL and some of the XML elements generated from this web service. Most of the XML elements will be in the namespace according to the JAXB mapping rules.(wsdl文件中当前方法下子标签<soap:operation soapAction="..."/>的值)

""

exclude

Used to exclude a method from the WebService.(是否从WebService服务中排除这个方法)

false(默认是不排除)

3、@javax.jws.WebParam(使用@WebParam来设置请求参数和soap消息元素名的映射),其中的属性:

Property Description Default

name

Name of the parameter.(参数的名字)

If the operation is RPC style and @WebParam.partName has not been specified, this is name of the wsdl:partrepresenting the parameter.(对应wsdl<part name="...."的值)

@WebMethod.operation Name, if the operation is document style and the parameter style is BARE.

Otherwise, the default is argN if the operation is document style or the parameter maps to a header, this is the local name of the XML element representing the parameter.

A name MUST be specified if the operation is document style, the parameter style is BARE, and the mode is OUT or INOUT.

@WebMethod.operation Name, if the operation is document style and the parameter style is BARE. Otherwise, the default isargN, where N represents the index of the parameter in the method signature (starting at arg0).(默认是arg+所在方法参数列的索引位)

targetNamespace

The XML namespace for the parameter. Only used if the operation is document style or the paramater maps to a header. If the target namespace is set to "", this represents the empty namespace.

The empty namespace, if the operation is document style, the parameter style is WRAPPED, and the parameter does not map to a header. Otherwise, the default is the targetNamespace for the Web Service.

mode

Represents the direction the parameter flows for this method. Possible values are ININOUT and OUTINOUT and OUTmodes can only be used with parameters that meet the requirements for a holder as classified by section 3.5 of the JAX-WS 2.0 specification. OUT and INOUT parameters can be used by all RPC and DOCUMENT bindings.(mode=Mode.IN或者mode=Mode.OUT,参数是输入或输出)

IN for non-holder parameters INOUT for holder parameters.

(不是Holder参数则为IN,如果是Holder参数则为INOUT)

header

Specifies whether the parameter should be carried in a header.(是否单独声明一个元素<xsd:element name="...")

FALSE(默认不用)

partName

Used to specify the partName for the parameter with RPC or DOCUMENT/BARE operations.

@WebParam.name

4、@javax.jws.WebResult(使用@WebResult来设置返回值和soap消息元素名的映射),其中的属性:

Property Description Default

name

The name of the return value in the WSDL and on the wire. For RPC bindings this is the part name of the return value in the response message. For DOCUMENT bindings this is the local name of the XML element representing the return value.(wsdl文件中方法返回信息子标签<part name="..."的值)

"return" for RPC and DOCUMENT/WRAPPED bindings. Method name + "Response" for DOCUMENT/BARE bindings.(RPC:默认"return",DOCUMENT/BARE:默认方法名+”Response“)

targetNamespace

The XML namespace for the return value. Only used if the operation is document style or the return value maps to a header. If the target namespace is set to "", this represents the empty namespace.

The empty namespace, if the operation is document style, the parameter style is WRAPPED, and the return value does not map to a header, Otherwise, the default is the targetNamespace for the Web Service.

header

Specifies whether the result should be carried in a header.

FALSE

partName

Used to specify the partName for the result with RPC or DOCUMENT/BARE operations.

@WebResult.name

5、@javax.jws.HandlerChain(使用@HandlerChain来定义程序处理链),其中的属性:

Property Description Default

file

Location of the file containing the handler chain definition. The location can be relative or absolute with in a classpath system. If the location is relative, it is relative to the package of the web service. If it is absolute, it is absolute from some path on the classpath.(处理链的配置文件路径,配置文件放在类路径下)

None

name

DEPRECATED The handler chain name from within the handler chain file.

""

6、@javax.jws.soap.SOAPBinding(使用@SOAPBinding指定soap消息格式)

Property Description Default

style

Defines the style for messages used in a web service. The value can be either DOCUMENT or RPC.

DOCUMENT

use

Defines the encoding used for messages used in web service. Can only be LITERAL for JAX-WS 2.2.

LITERAL

parameterStyle

Determines if the method's parameters represent the entire message body or whether the parameters are wrapped in a body element named after the operation. Choice of WRAPPED or BAREBARE can only be used with DOCUMENT style bindings.

WRAPPED

猜你喜欢

转载自luan.iteye.com/blog/1826774