Wsmetadata 1 0 FR Spec
Wsmetadata 1 0 FR Spec
Wsmetadata 1 0 FR Spec
JavaTM Platform
_______________________________________________
Technical Comments to: [email protected]
JSR-181
Java Community Process (JCP)
Version 1.0 June 1, 2005
Table of Contents
1
Introduction............................................................................................................. 4
1.1
Expert Group Members.................................................................................... 5
1.2
Acknowledgements.......................................................................................... 5
1.3
Conventions..................................................................................................... 5
1.4
Objectives........................................................................................................ 6
2
Concepts ................................................................................................................. 7
2.1
Programming Model Overview........................................................................ 7
2.2
Development Models....................................................................................... 7
2.3
Processor Responsibilities................................................................................ 8
2.4
Runtime Responsibilities ................................................................................. 9
2.5
Metadata Use................................................................................................... 9
2.6
Web Services Metadata.................................................................................. 11
3
Server Programming Model................................................................................... 13
3.1
Service Implementation Bean ........................................................................ 13
3.2
Service Endpoint Interface............................................................................. 13
3.3
Web Method.................................................................................................. 14
4
Web Services Metadata ......................................................................................... 15
4.1
Annotation: javax.jws.WebService ................................................................ 15
4.2
Annotation: javax.jws.WebMethod................................................................ 17
4.3
Annotation: javax.jws.Oneway ...................................................................... 18
4.4
Annotation: javax.jws.WebParam .................................................................. 19
4.5
Annotation: javax.jws.WebResult .................................................................. 22
4.6
Annotation: javax.jws.HandlerChain.............................................................. 24
4.7
Annotation: javax.jws.soap.SOAPBinding ..................................................... 26
4.8
Annotation: javax.jws.soap.SOAPMessageHandlers ...................................... 30
5
Java Mapping To XML/WSDL ............................................................................. 33
5.1
Service Endpoint Interface............................................................................. 33
5.2
Web Service Class Mapping .......................................................................... 33
5.3
Web Method Mapping ................................................................................... 34
6
SOAP Binding....................................................................................................... 35
6.1
Operation Modes ........................................................................................... 35
6.2
Headers ......................................................................................................... 36
7
Mapping JSR-181 to the J2EE 1.4 Runtime Environment ...................................... 38
7.1
Overview ....................................................................................................... 38
7.2
Implementation Models ................................................................................. 39
7.3
Service Endpoint Interface............................................................................. 39
7.4
Mapping from JSR-181 to JSR-109 Deployment Descriptors......................... 39
8
Using JSR-181 annotations to affect the shape of the WSDL ................................. 44
8.1
RPC Literal Style........................................................................................... 44
9
References............................................................................................................. 47
Appendix A: Relationship to Other Standards ............................................................... 48
Appendix B: Handler Chain Configuration File Schema................................................ 49
Appendix C: Non-Normative Examples of Alternate Binding Annotations.................... 50
C.1 Annotation Name: HttpGetBinding..................................................................... 50
Appendix D: Change Log.............................................................................................. 51
1 Introduction
This specification defines a simplified programming model that facilitates and accelerates
the development of enterprise Web Services. J2EE standard deployment technologies,
APIs, and protocols require the J2EE developer to master a substantial amount of
information. This JSR reduces the amount of information required to implement Web
Services on J2EE by using metadata to specify declaratively the Web Services that each
application provides. The metadata annotates the Java source file that implements the
Web Service. While the metadata is human readable and editable using a simple text
editor, graphical development tools can represent and edit the Java source file using
higher levels of abstraction specific to Web Services. This is a simpler and more
powerful development environment than traditional coding tools that are used to develop
source code using low level APIs.
This specification relies on the JSR-175 specification A Program Annotation Facility for
the JavaTM Programming Language for the Web Services metadata that annotates a Web
Service implementation. This document uses JSR-175 features as described in the Public
Draft Specification of JSR-175.
JSR-181 defines the syntax and semantics of Web Services metadata and default values
and implementers are expected to provide tools that map the annotated Java classes onto
a specific runtime environment. This specification does not define a Java environment in
which Web Services are run; however, the use of a J2SE 5.0 compiler is assumed. In
particular, JSR-181 expects features such as JAX-RPC 1.1 and JSR-109, along with the
compiler and language extensions from JSR-175 to be present.
A JSR-181 implementation MUST produce a deployable Java Web Service application
that can run in the target Java environment. The deployed application MUST exhibit the
proper behavior described by the Web Services metadata and Java source code. Any two
JSR-181 processors starting from the same valid annotated Java Web Services file MUST
produce equivalent Web Service applications, even though they may deploy in very
different Java environments. This consistency ensures portability of JSR-181 compliant
Java files.
1.2 Acknowledgements
Manoj Cheenath (BEA Systems), Don Ferguson (BEA Systems), Chris Fry (BEA
Systems), Neal Yin (BEA Systems), Beverley Talbott (BEA Systems), Matt Mihic and
Jim Trezzo have all provided valuable technical input to this specification.
1.3 Conventions
The keywords MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT,
SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this
document are to be interpreted as described in RFC 2119[11].
1.4 Objectives
The following objectives describe the scope of this specification:
Provide a simplified model for Web Service development that facilitates and
accelerates development.
Define a standard for to building and deploying Web Services without requiring
knowledge and implementation of generalized APIs and deployment descriptors.
Development of server applications that conform both to basic SOAP and WSDL
standards.
Building Web Services that can be deployed with the core Web Services APIs and
existing J2EE standards.
It is not a goal of this specification to support every feature or to enable the creation of
every Web Service that is possible to write with existing specifications. However, it is a
goal to make it easy to build the commonly needed types of Web Services.
2 Concepts
This section provides an overview of the following basic components and processes of
the JSR-181 specification:
Programming model for JSR-181 Web Services.
Use of metadata in JSR-181.
Non-normative processing model for a Web Service file.
Runtime requirements for a JSR-181 container
Annotations used for WSDL, binding and configuration.
The metadata is formally described in section 4.
Developers use a standard Java compiler with support for JSR-175 to compile and
validate the service implementation bean. The compiler uses the annotation type
declarations in the javax.jws and javax.jws.soap packages to check for syntax and
type mismatch errors in the Web Service metadata. The result of compilation is a Java
.class file containing the Web Service metadata along with the compiled Java code. The
class file format for these annotations is specified by JSR-175. Any Web Service
metadata that this JSR designates as runtime-visible will also be accessible using the
standard java.lang.reflect classes from the run-time environment.
Ensuring that annotation values match extended types. The Java compiler can
ensure that a particular annotation member-value is of the type specified in the
annotation type declaration. However, JSR-175 restricts annotations to simple
types such as primitives, Strings, and enums. As a result, the compiler cannot
ensure that (for example) an annotation member is a valid URL. It can only
verify that the member is a String. The JSR-181 implementation MUST perform
the additional type checking to ensure that the value is a valid URL.
Ensuring that annotations match the code. For example, the developer MAY use
the @Oneway annotation to indicate that a particular operation does not produce an
output message. If the operation is marked @Oneway, it MUST NOT have a return
value or out/in-out parameters. The JSR-181 implementation MUST provide
feedback if this constraint is violated.
Ensuring that annotations are consistent with respect to other annotations. For
example, it is not legal to annotate a method with the @Oneway annotation unless
there is also a corresponding @WebMethod annotation. The JSR-181
implementation MUST ensure these constraints are met.
Note: Certain types of errors MAY only be caught when the Web Service is deployed or
run.
Java source or other annotations. For example, the default value for the
@WebService.name annotation is the simple name of the Java class or interface. This
value cannot be represented directly as a JSR-175 default. In scenarios where JSR-175
defaults are not sufficient to describe the required default, a marker constant is used
instead. On seeing this marker constant, the JSR-181 processor treats the member-value
as though it had the computed default described in this document. For example, when the
JSR-181 processor encounters a @WebService.name annotation with a value of (the
empty string), it behaves as though the name of the Web Service were the name of the
Java class.
@WebMethod
public String helloWorld()
{
return "Hello World!";
}
}
JSR-181 includes a full set of metadata tags to define the Web Services that are provided
by a service implementation bean. Most of these metadata tags have reasonable defaults,
which are explicitly called out in this document. The Java Web Service author can avoid
providing tags for the most common Web Service definitions.
The following sections give an overview of the types of annotations provided by JSR181.
11
12
All of the methods on the service endpoint interface are mapped to WSDL
operations, regardless of whether they include a @WebMethod annotation. A
method MAY include a @WebMethod annotation to customize the mapping to
WSDL, but is not REQUIRED to do so.
The service endpoint interface MAY include other JSR-181 annotations to control
the mapping from Java to WSDL. Section 7.1 contains the complete list of
annotations allowed on a service endpoint interface.
14
targetNamespace
serviceName
wsdlLocation
Meaning
The name of the Web Service. Used as the
name of the wsdl:portType when mapped to
WSDL 1.1
The XML namespace used for the WSDL and
XML elements generated from this Web
Service.
Default
The simple name
of the Java class
or interface
Implementationdefined, as
described in JAXRPC 1.1 [5],
section 5.5.2.
Typically derived
from the package
containing the
Web Service.
The service name of the Web Service. Used as The simple name
of the Java class +
the name of the wsdl:service when mapped
Service"
to WSDL 1.1.
Not allowed on interfaces.
The location of a pre-defined WSDL
None
describing the service. The wsdlLocation is a
URL (relative or absolute) that refers to a preexisting WSDL file. The presence of a
wsdlLocation value indicates that the service
implementation bean is implementing a predefined WSDL contract. The JSR-181 tool
MUST instead provide feedback if the service
implementation bean is inconsistent with the
portType and bindings declared in this
WSDL. Note that a single WSDL file might
contain multiple portTypes and multiple
bindings. The annotations on the service
implementation bean determine the specific
portType and bindings that correspond to the
Web Service.
15
Member-Value
endpointInterface
Meaning
The complete name of the service endpoint
interface defining the services abstract Web
Service contract. This annotation allows the
developer to separate the interface contract
from the implementation. If this annotation is
present, the service endpoint interface is used
to determine the abstract WSDL contract
(portType and bindings). The service endpoint
interface MAY include JSR-181 annotations to
customize the mapping from Java to WSDL.
The service implementation bean MAY
implement the service endpoint interface, but
is not REQUIRED to do so.
Not allowed on interfaces.
Default
None the Web
Service contract is
generated from
annotations on the
service
implementation
bean. If a service
endpoint interface
is required by the
target
environment, it
will be generated
into an
implementationdefined package
with an
implementationdefined name.
4.1.3 Example
Java source:
/**
* Annotated Implementation Object
*/
@WebService(
name = "EchoService",
targetNamespace = "http://www.openuri.org/2004/04/HelloWorld"
)
public class EchoServiceImpl {
@WebMethod
public String echo(String input) {
return input;
}
}
16
Meaning
Name of the wsdl:operation matching
this method.
The action for this operation. For SOAP
bindings, this determines the value of
the SOAPAction header
Default
The name of the
Java method
""
4.2.3 Example
Java source:
@WebService
public class MyWebService {
@WebMethod(operationName = "echoString", action="urn:EchoString")
public String echo(String input) {
return input;
}
}
Resulting WSDL:
<definitions>
<portType name="MyWebService">
<operation name="echoString"/>
<input message="echoString"/>
<output message="echoStringResponse"/>
</operation>
</portType>
<binding name="PingServiceHttpSoap">
<operation name="echoString">
<soap:operation soapAction="urn:EchoString"/>
17
</operation>
</binding>
</definitions>
4.3.3 Example
Java source:
@WebService
public class PingService {
@WebMethod
@Oneway
public void ping() {
}
};
Resulting WSDL:
<definitions>
<message name="ping"/>
<portType name="PingService">
<operation name="ping">
<input message="ping"/>
</operation>
</portType>
</definitions>
18
targetNamespace
mode
header
Meaning
Name of the parameter as it appears
in the WSDL. For RPC bindings,
this is name of the wsdl:part
representing the parameter. For
document bindings, this is the local
name of the XML element
representing the parameter.
The XML namespace for the
parameter. Only used with
document bindings, where the
parameter maps to an XML element.
The direction in which the parameter
is flowing. One of IN, OUT, or
INOUT. The OUT and INOUT
modes may only be specified for
parameter types that conform to the
JAX-RPC definition of Holder
types. See JAX-RPC 1.1 [5],
section 4.3.5. OUT and INOUT
modes are only supported for RPC
bindings or for parameters that map
to headers.
If true, the parameter is pulled from
a message header rather then the
message body.
19
Default
Name of the parameter
as it appears in the
argument list.
The targetNamespace
for the Web Service
IN
false
4.4.3 Example
Java Source:
@WebService(targetNamespace="http://www.openuri.org/jsr181/WebParamExam
ple")
@SOAPBinding(style=SOAPBinding.Style.RPC)
public class PingService {
@WebMethod(operationName = "PingOneWay")
@Oneway
public void ping(@WebParam(name="Ping") PingDocument p) {
}
@WebMethod(operationName = "PingTwoWay")
public void ping(
@WebParam(name="Ping", mode=WebParam.Mode.INOUT)
PingDocumentHolder p) {
}
@WebMethod(operationName = "SecurePing")
@Oneway
public void ping(
@WebParam(name="Ping") PingDocument p,
@WebParam(name="SecHeader", header=true)
SecurityHeader secHdr) {
}
};
Resulting WSDL:
<definitions
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://www.openuri.org/jsr181/WebParamExample"
xmlns:wsdl="http://www.openuri.org/jsr181/WebParamExample"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="http://www.openuri.org/jsr181/WebParamExample">
<types>
<s:schema elementFormDefault="qualified"
targetNamespace="http://www.openuri.org/jsr181/WebParamExample">
<s:complexType name="Ping">
. . .
</s:complexType>
<s:complexType name="SecurityHeader">
. . .
</s:complexType>
20
21
<soap:operation soapAction="http://openuri.org/SecurePing"/>
<input>
<soap:body parts="Ping" use="literal"/>
<soap:header message="SecurePing" part="SecHeader"
use="literal"/>
</input>
</operation>
</binding>
</definitions>
targetNamespace
Meaning
Name of return value as it appears in
the WSDL and messages on the
wire. For RPC bindings, this is the
name of the wsdl:part representing
the return value. For document
bindings, this is the local name of
the XML element representing the
return value.
The XML namespace for the return
value. Only used with document
bindings, where the return value
maps to an XML element.
4.5.3 Example
Java Source:
@WebService
public class CustomerService {
@WebMethod
@WebResult(name="CustomerRecord")
public CustomerRecord locateCustomer(
@WebParam(name="FirstName") String firstName,
22
Default
return
The targetNamespace
for the Web Service.
Resulting WSDL:
<definitions>
<types>
<complexType name="CustomerRecord">
...
</complexType>
<complexType name="USAddress">
...
</complexType>
<element name="locateCustomer">
<complexType>
<sequence>
<element name="FirstName" type="xs:string"/>
<element name="LastName" type="xs:string"/>
<element name="Address" type="USAddress"/>
</sequence>
</complexType>
</element>
<element name="locateCustomerResponse">
<complexType>
<sequence>
<element name="CustomerRecord" type="CustomerRecord"/>
</sequence>
</complexType>
</element>
</types>
<message name="locateCustomer">
<part name="parameters" element="tns:locateCustomer"/>
</message>
<message name="locateCustomerResponse">
<part name="parameters" element="tns:locateCustomerResponse"/>
</message>
<portType name="CustomerService">
<operation name="locateCustomer">
<input message="tns:locateCustomer"/>
<output message="tns:locateCustomerResponse"/>
</operation>
</portType>
</definitions>
23
Meaning
Location of the handler chain file. The location supports 2
formats.
Default
None
4.6.3 Examples
Example 1
Java Source:
Located in /home/mywork/src/com/jsr181/examples/
package com.jsr181.examples
24
None
@WebService
@HandlerChain(
file="config/ProjectHandlers.xml",
name="StandardHandlerChain")
public class MyWebService {
};
Example 2
package com.jsr181.examples
25
@WebService
@HandlerChain(
file="http://myhandlers.foo.com/ProjectHandlers.xml",
name="StandardHandlerChain")
public class MyWebService {
};
use
parameterStyle
Meaning
Defines the encoding style for messages
send to and from the Web Service. One of
DOCUMENT or RPC.
Defines the formatting style for messages
sent to and from the Web Service. One of
LITERAL or ENCODED.
Determines whether method parameters
represent the entire message body, or
whether the parameters are elements
wrapped inside a top-level element named
after the operation.
26
Default
DOCUMENT
LITERAL
WRAPPED
4.7.3 Examples
Example 1 RPC/LITERAL
Java source:
@WebService
@SOAPBinding(
style = SOAPBinding.Style.RPC,
use
= SOAPBinding.Use.LITERAL)
public class ExampleService {
@WebMethod
public String concat(String first, String second, String third) {
return first + second + third;
}
}
Resulting WSDL:
<definitions
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://www.openuri.org/jsr181/SoapBindingExample1"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="http://www.openuri.org/jsr181/SoapBindingExample1">
<message name="concat">
<part name="first" type="xs:string"/>
<part name="second" type="xs:string"/>
<part name="third" type="xs:string"/>
</message>
<message name="concatResponse">
<part name="return" type="xs:string"/>
</message>
<portType name="ExampleService">
<operation name="concat">
<input message="tns:concat"/>
<output message="tns:concatResponse"/>
</operation
</portType>
<binding name="ExampleServiceHttpSoap" type="ExampleService">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="concat">
<soap:operation
soapAction="http://www.openuri.org/jsr181/SoapBindingExample1/concat"/>
27
<input>
<soap:body parts="first second third" use="literal"/>
</input>
<output>
<soap:body parts="return" use="literal"/>
</output>
</binding>
</definitions>
Example 2 DOCUMENT/LITERAL/BARE
Java source:
@WebService
@SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)
public class DocBareService {
@WebMethod( operationName="SubmitPO" )
public SubmitPOResponse submitPO(SubmitPORequest submitPORequest) {
}
}
Resulting WSDL:
<definitions
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://www.openuri.org/jsr181/SoapBindingExample2"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="http://www.openuri.org/jsr181/SoapBindingExample2">
<types>
<s:schema elementFormDefault="qualified"
targetNamespace="http://www.openuri.org/jsr181/SoapBindingExample2">
<s:element name="SubmitPORequest">
. . .
</s:element>
<s:element name="SubmitPOResponse">
. . .
</s:element>
</s:schema>
</types>
<message name="SubmitPO">
<part name="parameters" element="tns:SubmitPORequest"/>
</message>
<message name="SubmitPOResponse">
<part name="parameters" type="tns:SubmitPOResponse"/>
</message>
<portType name="DocBareService">
28
<operation name="SubmitPO">
<input message="tns:SubmitPO"/>
<output message="tns:SubmitPOResponse"/>
</operation
</portType>
<binding name="DocBareServiceHttpSoap" type="ExampleService">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="SubmitPO">
<soap:operation
soapAction="http://www.openuri.org/jsr181/SoapBindingExample2/SubmitPO"
/>
<input>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body parts="parameters" use="literal"/>
</output>
</binding>
</definitions>
Example 3 DOCUMENT/LITERAL/WRAPPED
Java source:
@WebService
@SOAPBinding(
style
= SOAPBinding.Style.DOCUMENT,
use
= SOAPBinding.Use.LITERAL,
parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class DocWrappedService
@WebMethod(operationName = "SubmitPO")
@WebResult(name="PurchaseOrderAck")
public PurchaseOrderAck submitPO(
@WebParam(name="PurchaseOrder") PurchaseOrder purchaseOrder) {
}
}
Resulting WSDL:
<definitions
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://www.openuri.org/jsr181/SoapBindingExample3"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="http://www.openuri.org/jsr181/
SoapBindingExample3">
<types>
<s:schema elementFormDefault="qualified"
targetNamespace="http://www.openuri.org/jsr181/SoapBindingExample3">
<s:element name="SubmitPO">
29
<complexType>
<sequence>
<element name="PurchaseOrder"
type="tns:PurchaseOrder"/>
. . .
</s:element>
<s:element name="SubmitPOResponse">
. . .
</s:element>
</s:schema>
</types>
<message name="SubmitPO">
<part name="parameters" element="tns:SubmitPO"/>
</message>
<message name="SubmitPOResponse">
<part name="parameters" type="tns:SubmitPOResponse"/>
</message>
<portType name="DocWrappedService">
<operation name="SubmitPO">
<input message="tns:SubmitPO"/>
<output message="tns:SubmitPOResponse"/>
</operation
</portType>
<binding name="ExampleServiceHttpSoap" type="ExampleService">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="SubmitPO">
<soap:operation
soapAction="http://www.openuri.org/jsr181/SoapBindingExample3/SubmitPO"
/>
<input>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body parts="parameters" use="literal"/>
</output>
</binding>
</definitions>
30
Member-Value
name
Meaning
Name of the handler.
className
initParams
roles
headers
Default
Name of the
handler class
None
No init params
4.8.3 Example:
Java source (simple scenario):
31
@WebService
@SOAPMessageHandlers({
@SOAPMessageHandler(
className = "com.fabrikam.handlers.LogHandler"),
@SOAPMessageHandler(
className = "com.fabrikam.handlers.AuthorizationHandler"),
@SOAPMessageHandler(
className = "com.fabrikam.handlers.RoutingHandler")
})
public class MyWebService {
@WebMethod
public String echo(String input) {
return input;
}
};
32
As described in JAX-RPC 1.1 [5] section 5.2, a service endpoint interface maps to a
wsdl:portType element within the wsdl:definitions for the containing package.
The local name and namespace of the wsdl:portType map to the values of the service
endpoint interfaces @WebService.name and @WebService.targetNamespace attributes,
respectively.
33
Each wsdl:port MUST be of the same wsdl:portType, but MAY have different
bindings.
The names of the wsdl:port and wsdl:binding sections are not significant and
are left implementation-defined.
34
6 SOAP Binding
This section defines a standard mapping from a service endpoint interface or service
implementation bean to the SOAP 1.1 binding. Implementers MAY also support other
bindings, but these bindings are non-standard. If JSR-181 implementation supports
bindings other than SOAP 1.1, it MUST include a mechanism to selectively enable or
disable these bindings.
By default JSR-181 follows the SOAP binding defined in JAX-RPC 1.1 [5], section 6.
The @SOAPBinding, @WebParam, and @WebResult annotations allow the developer to
further customize this binding for a particular Web Service.
Implementations MAY optionally support operation modes with the encoded use
(document or rpc style). The developer MAY indicate which operation mode is in effect
by specifying the appropriate @SOAPBinding.style and @SOAPBinding.use annotations
at the class or interface level.
6.2 Headers
Parameters annotated with the @WebParam.header attribute map to SOAP headers
instead of elements in the SOAP body. Header parameters appear as parts in the
operations input message, output message, or both depending on the value of the
36
annotations determine the QName of the XML element representing the header.
37
JSR 181
Source or
Class File
JSR-181 Processor
produces
Implementation
Classes
WSDL
webservices.
xml
Jax-rpcmapping.xml
One or more service implementation beans are passed to the JSR-181 processor in source
or class form. The JSR-181 processor examines the annotations in each Web Service file
and uses this information to generate a JSR-109 deployment unit (EAR or WAR file).
The JSR-109 deployment unit contains the following artifacts:
The compiled Java classes required for deployment. This includes the Web
Service implementations, all referenced Java classes, and any generated Home or
Remote interfaces.
WSDL documents describing each service. If @WebService.wsdlLocation is
specified, the WSDL file will be copied with all of its dependencies from this
location and placed into the deployment unit. If @WebService.wsdlLocation is
not specified, the WSDL file is generated from the annotations in the service
implementation bean.
Service endpoint interfaces defining the methods implemented by each service.
The service endpoint interface may be written by the developer or generated from
the annotations on the service implementation bean.
The webservices.xml deployment descriptor. This deployment descriptor
contains references to all of the Web Services in the deployment unit. There will
38
be one webservice entry for each Web Service class processed by the JSR-181
processor. Section 7.4.1 Mapping from JSR-181 to webservices.xml
describes the mapping from JSR-181 annotations to entries in webservices.xml.
The jax-rpc-mapping.xml deployment descriptor. Section 7.4.3 - Mapping
from JSR-181 to jax-rpc-mapping.xml describes the mapping from JSR-181
annotations to entries in jax-rpc-mapping.xml.
One of either a web.xml or ejb-jar.xml deployment descriptor. The JSR-181
processor will generate either a web.xml deployment descriptor (for servlet
endpoints) or an ejb-jar.xml deployment descriptor (for stateless session beans)
depending on the implementation model chosen for the service. See the next
section for more information on selecting an implementation model.
Once generated, the values in the deployment descriptors may be overridden by the
deployer or administrator using standard deployment tools, including JSR 88 deployment
plans. This capability allows customization of the Web Service without requiring access
to the source code.
webservices/webservice/jax-rpc-mappingfile
webservices/webservice/portcomponent/port-component-name
webservices/webservice/portcomponent/wsdl-port
webservices/webservice/portcomponent/service-endpoint-interface
webservices/webservice/service-implbean/ejb-link or
webservices/webservice/service-implbean/service-link
webservices/webservice/handler
@SOAPMessageHandlers or
@HandlerChain
40
className = "com.fabrikam.handlers.RoutingHandler"
)
})
public class StockQuoteServiceImpl {
@WebMethod(operationName="GetLastTrade")
public long getLastTrade(String tickerSymbol) {
// . . .
}
@WebMethod(operationName="GetTickerSymbols")
public String[] getTickerSymbols() {
// . . .
}
}
Resulting webservices.xml:
<webservices>
<webservice
xmlns:ns1="http://www.openuri.org/MyNamespace">
<wsdl-file>StockQuoteService.wsdl</wsdl-file>
<port-component>
<port-component-name>
StockQuoteServiceSoapHttp
</port-component-name>
<service-endpoint-interface>
StockQuoteService
</service-endpoint-interface>
<wsdl-port>ns1:StockQuoteServiceSoapHttpPort</wsdl-port>
<handler>
<handler-name>
com.fabrikam.handlers.LogHandler
</handler-name>
<handler-class>
com.fabrikam.handlers.LogHandler
</handler-class>
<init-param>
<param-name>logCategory</param-name>
<param-value>MyService</param-value>
</init-param>
</handler>
<handler>
<handler-name>
com.fabrikam.handlers.AuthorizationHandler
</handler-name>
<handler-class>
com.fabrikam.handlers.AuthorizationHandler
</handler-class>
<soap-role>SecurityProvider</soap-role>
<soap-header
xmlns:ns2=http://openuri.org/examples/security>
ns2:SecurityHeader
</soap-header>
</handler>
41
<handler>
<handler-name>
com.fabrikam.handlers.RoutingHandler
</handler-name>
<handler-class>
com.fabrikam.handlers.RoutingHandler
</handler-class>
</handler>
<ejb-link>StockQuoteServiceEJB</ejb-link>
</port-component>
</webservice>
</webservices>
Implementation defined
@WebMethod.operationName
Present if
@SOAPBinding.parameterStyle is
WRAPPED
Java Source:
@WebService(targetNamespace="http://www.openuri.org/MyNamespace"
name="StockQuoteService")
@SOAPBinding(name="StockQuoteServiceSoap")
public class StockQuoteServiceImpl {
@WebMethod(operationName="GetLastTrade")
public GetLastTradeResponse getLastTrade(
42
GetLastTradeRequest request) {
// . . .
}
@WebMethod(operationName="GetTickerSymbols")
public String[] getTickerSymbols() {
// . . .
}
}
Resulting java-xml-rpc-mapping.xml:
<java-wsdl-mapping>
<service-endpoint-mapping
xmlns:ns1="http://www.openuri.org/MyNamespace">
<service-endpoint-interface>StockQuoteService</serviceendpoint-interface>
<wsdl-port-type>ns1:StockQuoteService</wsdl-port-type>
<wsdl-binding>ns1:StockQuoteServiceSoap</wsdl-binding>
<service-endpoint-method-mapping>
<java-method-name>getLastTrade</java-method-name>
<wsdl-operation>GetLastTrade</wsdl-operation>
<wrapped-element/>
</service-endpoint-method-mapping>
<service-endpoint-method-mapping>
<java-method-name>getTickerSymbols</java-method-name>
<wsdl-operation>GetTickerSymbols</wsdl-operation>
<wrapped-element/>
</service-endpoint-method-mapping>
</service-endpoint-mapping>
</java-wsdl-mapping>
43
Resulting WSDL:
<definitions
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://openuri.org/11/2003/ExampleWebService"
xmlns:wsdl="http://openuri.org/11/2003/ExampleWebService"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
44
targetNamespace="http://openuri.org/11/2003/ExampleWebService">
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<types>
<s:schema elementFormDefault="qualified"
targetNamespace="http://openuri.org/11/2003/ExampleWebService">
<s:complexType name="Customer">
. . .
</s:complexType>
<s:element name="Customer" type="Customer"/>
<s:complexType name="LoginToken">
. . .
</s:complexType>
<s:complexType name="TransferDocument">
. . .
</s:complexType>
<s:element name="Token" type="LoginToken"/>
<s:element name="notifyTransfer">
<s:complexType>
<s:sequence>
<s:element name="CustomerId" type="s:string"
minOccurs="1" maxOccurs="1"/>
<s:element name="TransferData" type="TransferDocument"
minOccurs="1" maxOccurs="1"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</types>
<message name="notifyTransfer">
<part name="parameters" element="NotifyTransfer"/>
</message>
<message name="notifyTransferHeaders">
<part name="Token" element="Token"/>
</message>
<message name="createCustomer">
<part name="Customer" type="Customer"/>
</message>
<message name="createCustomerHeaders">
<part name="Token" type="Token"/>
</message>
<message name="createCustomerResponse">
<part name="CustomerId" type="s:string"/>
</message>
<message name="login">
<part name="UserName" type="s:string"/>
45
46
9 References
1. JSR-175 A Metadata Facility for the JavaTM Programming Language
http://jcp.org/en/jsr/detail?id=175
2. JSR-88 J2EE Application Deployment
http://jcp.org/en/jsr/detail?id=88
3. XML Schema 1.0
http://www.w3.org/TR/xmlschema-1/
4. J2EE 1.4
http://jcp.org/en/jsr/detail?id=151
5. JAX-RPC V1.1
http://www.jcp.org/en/jsr/detail?id=101
6. Implementing Enterprise Web Services 1.1 (was JSR-109)
http://www.jcp.org/en/jsr/detail?id=921
7. Web Services Definition Language (WSDL) 1.1
http://www.w3.org/TR/wsdl
8. Simple Object Access Protocol (SOAP) 1.1
http://www.w3.org/TR/2000/NOTE-SOAP-20000508/
9. Apache AXIS "JWS" drop-in deployment of Web Services
10. BEA WebLogic Workshop "JWS" annotated Java Web Services
11. RFC 2119: Keywords for use in RFCs to Indicate Requirement Levels
http://www.ietf.org/rfc/rfc2119.txt
47
48
49
Meaning
The location of the HTTP GET endpoint.
When defined at the class level, defines as
the base URI for all operations on the
service. When defined at the method level,
defines the URI for a particular operation
relative to the base URI for the service.
C.1.3 Example
@WebService
@HttpGetBinding(location="MyWebServices")
public class MyWebServiceImpl {
@WebMethod
@HttpGetBinding(location="ExampleOperation")
public void myOperation() {
}
};
50
Default
Implementation-defined
51