[code.view]

[top] / java / jaxws / 2.0 / docs / ch03.html

<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>Users Guide</title><link rel="stylesheet" href="style/documentation.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.75.2"><link rel="home" href="index.html" title="JAX-WS Release Documentation"><link rel="up" href="index.html" title="JAX-WS Release Documentation"><link rel="prev" href="ch02.html" title="Release Notes"><link rel="next" href="ch04.html" title="Tools"><script xmlns:fo="http://www.w3.org/1999/XSL/Format" type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-2105126-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Users Guide</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch02.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ch04.html">Next</a></td></tr></table><hr></div><small xmlns:fo="http://www.w3.org/1999/XSL/Format" class="small">Links: <a href="index.html">Table of Contents</a> | <a href="release-documentation.html">Single HTML</a> | <a href="release-documentation.pdf">Single PDF</a></small><div lang="en" class="chapter" title="Users Guide" id="users-guide"><div class="titlepage"><div><div><h2 class="title">Users Guide</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="ch03.html#users-guide-overview">1. Overview</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#introduction">1.1. Introduction</a></span></dt><dt><span class="section"><a href="ch03.html#features">1.2. Features</a></span></dt><dt><span class="section"><a href="ch03.html#programming-model">1.3. Programming Model</a></span></dt><dt><span class="section"><a href="ch03.html#useful-information">1.4. Useful Information</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-provider">2. Provider</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#section-3091238697838234">2.1. <code class="literal">Provider&lt;Source&gt;</code> and
        <code class="literal">PAYLOAD</code></a></span></dt><dt><span class="section"><a href="ch03.html#section-8519606736474974">2.2. <code class="literal">Provider&lt;SOAPMessage&gt;</code> and
        <code class="literal">MESSAGE</code></a></span></dt><dt><span class="section"><a href="ch03.html#section-7319353703410434">2.3. <code class="literal">Provider&lt;Source&gt;</code> and
        <code class="literal">MESSAGE</code></a></span></dt><dt><span class="section"><a href="ch03.html#section-674124516240791">2.4. WSDL Customization</a></span></dt><dt><span class="section"><a href="ch03.html#section-648626808421419">2.5. The <code class="literal">sun-jaxws.xml</code> file</a></span></dt><dt><span class="section"><a href="ch03.html#section-343591403757231">2.6. Provider and Binding</a></span></dt><dt><span class="section"><a href="ch03.html#section-330867941262645">2.7. RESTful Provider endpoints</a></span></dt><dt><span class="section"><a href="ch03.html#section-017933327977469">2.8. Provider and Handlers</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-asyncprovider">3. AsyncProvider</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#section-091974998856598">3.1. <code class="literal">AsyncProvider</code> Example</a></span></dt><dt><span class="section"><a href="ch03.html#section-930633228695613">3.2. <code class="literal">AsyncProvider</code> sample</a></span></dt><dt><span class="section"><a href="ch03.html#section-5233554712491355">3.3. <code class="literal">AsyncService</code> sample</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-dispatch">4. Dispatch</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#section-71379735580733">4.1. Programming Model</a></span></dt><dt><span class="section"><a href="ch03.html#section-21282255346754875">4.2. Dispatch and Asynchronous Invocations</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-asynchronous-client">5. Asynchronous Client</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#section-346120708971664">5.1. Asynchronous Invocation Using Static Stub</a></span></dt><dt><span class="section"><a href="ch03.html#section-85273158180115">5.2. Asynchronous Invocation Using Dispatch</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-handler">6. Handler</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#section-524340464580105">6.1. Handler Types</a></span></dt><dt><span class="section"><a href="ch03.html#section-276528078695232">6.2. MessageContext</a></span></dt><dt><span class="section"><a href="ch03.html#section-165423693536683">6.3. Handler Chain Configuration</a></span></dt><dt><span class="section"><a href="ch03.html#section-8594509924044">6.4. Handler Samples</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-mtom-and-swaref">7. MTOM and Swaref</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#mtom-and-xop">7.1. MTOM and XOP</a></span></dt><dt><span class="section"><a href="ch03.html#mtom-in-jaxws-2-0">7.2. MTOM in JAX-WS 2.0</a></span></dt><dt><span class="section"><a href="ch03.html#swaref">7.3. swaRef</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-soap-1-2">8. SOAP 1.2</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#section-94073181229507">8.1. Introduction</a></span></dt><dt><span class="section"><a href="ch03.html#section-627071591090577">8.2. SOAP 1.2 Endpoint</a></span></dt><dt><span class="section"><a href="ch03.html#section-696486497021005">8.3. Client</a></span></dt><dt><span class="section"><a href="ch03.html#section-7037754311590527">8.4. Samples</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-wsdl-customization">9. WSDL Customization</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#declaring-customizations">9.1. Declaring Customizations</a></span></dt><dt><span class="section"><a href="ch03.html#standard-customizations">9.2. Standard Customizations</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-annotations">10. Annotations</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#section-031540603185018">10.1. Overview</a></span></dt><dt><span class="section"><a href="ch03.html#jsr-181">10.2. JSR 181 (Web Services Metadata) Annotations</a></span></dt><dt><span class="section"><a href="ch03.html#jsr-224-jax-ws-annotations-outline">10.3. JSR 224 (JAX-WS) Annotations</a></span></dt><dt><span class="section"><a href="ch03.html#jsr-222-jaxb-annotations-outline">10.4. JSR 222 (JAXB) Annotations</a></span></dt><dt><span class="section"><a href="ch03.html#jsr-250-common-annotations">10.5. JSR 250 (Common Annotations) Annotations</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-why-ws-addressing">11. Why WS-Addressing?</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#what-is-ws-addressing">11.1. What is WS-Addressing?</a></span></dt><dt><span class="section"><a href="ch03.html#ws-addressing-versions">11.2. WS-Addressing Versions</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-ws-addressing">12. WS-Addressing</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#ws-addressing-in">12.1. WS-Addressing in JAX-WS RI</a></span></dt><dt><span class="section"><a href="ch03.html#why-ws-addressing">12.2. Why WS-Addressing?</a></span></dt><dt><span class="section"><a href="ch03.html#describing-ws-addressing-in-wsdl">12.3. Describing WS-Addressing in WSDL</a></span></dt><dt><span class="section"><a href="ch03.html#configuring-addressing-on-endpoint">12.4. Configuring Addressing on Endpoint</a></span></dt><dt><span class="section"><a href="ch03.html#on-the-client-side">12.5. On the client side</a></span></dt><dt><span class="section"><a href="ch03.html#when-is-ws-addressing-engaged">12.6. When is WS-Addressing engaged?</a></span></dt><dt><span class="section"><a href="ch03.html#associating-action-with-an-operation">12.7. Associating Action with an operation</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-stateful-webservice">13. Stateful Webservice</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#introduction-1">13.1. Introduction</a></span></dt><dt><span class="section"><a href="ch03.html#usage">13.2. Usage</a></span></dt><dt><span class="section"><a href="ch03.html#things-to-consider">13.3. Things To Consider</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-catalog">14. Catalog</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#section-529979392543239">14.1. Catalog Support</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-war-file-packaging">15. WAR File Packaging</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#section-5694250262578">15.1. The WAR Contents</a></span></dt><dt><span class="section"><a href="ch03.html#the-sun-jaxws-xml-file">15.2. The <code class="literal">sun-jaxws.xml</code> File</a></span></dt><dt><span class="section"><a href="ch03.html#section-42577169574826">15.3. The <code class="literal">web.xml</code> File</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-interoperability">16. Interoperability</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#section-4101350549640481">16.1. WSDL and Message Level Interoperability</a></span></dt><dt><span class="section"><a href="ch03.html#section-325661411410258">16.2. .NET 3.5 Interoperability</a></span></dt></dl></dd><dt><span class="section"><a href="ch03.html#users-guide-endpoint-api">17. Endpoint API</a></span></dt><dd><dl><dt><span class="section"><a href="ch03.html#section-0499646435494807">17.1. <code class="literal">Endpoint</code></a></span></dt><dt><span class="section"><a href="ch03.html#section-2491869058427427">17.2. <code class="literal">Endpoint</code> and
        <code class="literal">Properties</code></a></span></dt><dt><span class="section"><a href="ch03.html#section-9038221558727715">17.3. <code class="literal">Endpoint</code> and
        <code class="literal">Binding</code></a></span></dt><dt><span class="section"><a href="ch03.html#section-091994350952741">17.4. <code class="literal">Endpoint</code> and
        <code class="literal">metadata</code></a></span></dt></dl></dd></dl></div><div lang="en" class="section" title="1.&nbsp;Overview"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-overview">1.&nbsp;Overview</h2></div></div></div><div class="section" title="1.1.&nbsp;Introduction"><div class="titlepage"><div><div><h3 class="title" id="introduction">1.1.&nbsp;Introduction</h3></div></div></div><p>This document describes the new features available in this
        release of the JAX-WS RI. The main focus of this
        document is to describe the tools used to develop
        JAX-WS RI 2.2.7 web service endpoints and clients. Readers of
        this document should be familiar with web services <a class="link" href="http://www.w3.org/TR/2000/REC-xml-20001006" target="_top">XML</a>,
        <a class="link" href="http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/" target="_top">XML
        Schema</a> and <a class="link" href="http://www.w3.org/TR/2001/NOTE-wsdl-20010315" target="_top">WSDL</a>.
        Familiarity with <a class="link" href="http://jcp.org/en/jsr/detail?id=101" target="_top">JAX-RPC 1.1</a>
        may also be beneficial but is not necessary.</p><p>The documentation/samples discusses how to use JAX-WS in a
        non-Java EE 5 servlet container using a proprietary deployment
        descriptor <code class="literal">sun-jaxws.xml</code> and servlet
        <code class="literal">com.sun.xml.ws.transport.http.servlet.WSServlet</code>.
        This means that you can run JAX-WS RI applications
        in any servlet container that has been enabled with the
        JAX-WS RI. Applications that use the proprietary DD
        and servlet will run in a JAX-WS RI enabled Java EE
        5 servlet container, but they will be non-portable. If you wish to use
        JAX-WS in a Java EE container in a Java EE portable manner you need to
        use the standard Java EE 5 deployment descriptor; please refer to the
        <a class="link" href="http://java.sun.com/javaee/index.jsp" target="_top">Java EE
        5</a> or <a class="link" href="http://glassfish.java.net/" target="_top">Glassfish</a>
        documentation/samples. The majority of the documentation included with
        JAX-WS is valid with Java EE 5 as well.</p></div><div class="section" title="1.2.&nbsp;Features"><div class="titlepage"><div><div><h3 class="title" id="features">1.2.&nbsp;Features</h3></div></div></div><div class="section" title="1.2.1.&nbsp;JAX-WS 2.2 API"><div class="titlepage"><div><div><h4 class="title" id="jax-ws-api">1.2.1.&nbsp;JAX-WS 2.2 API</h4></div></div></div><p>JAX-WS 2.2 is a Maintainence
            Release of JAXWS 2.0 API.</p><p>JAX-WS 2.2 has the following new
            features from JAX-WS 2.1 specification:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Support for JAXB 2.2 APIs (JSR 222)</p></li><li class="listitem"><p>Support for WS-Addressing 1.0 - Metadata
                    specification</p></li><li class="listitem"><p>Support for <code class="literal">@XmlElement</code> on SEI's
                    wrapper parameter</p></li><li class="listitem"><p>Support for <code class="literal">@XmlType</code> on exception
                    classes</p></li><li class="listitem"><p>HTTP SPI</p></li><li class="listitem"><p>Provide API to create Endpoint with features</p></li></ul></div><p>JAX-WS 2.1 has the following new features from JAX-WS 2.0
            specification:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>WS-Addressing support</p></li><li class="listitem"><p>APIs for EndpointReference </p><div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p>Creation </p><div class="itemizedlist"><ul class="itemizedlist" type="square"><li class="listitem"><p><code class="literal">BindingProvider.getEndpointReference()</code></p></li><li class="listitem"><p><code class="literal">Endpoint.getEndpointReference()</code></p></li><li class="listitem"><p><code class="literal">MessageContext.getEndpointReference()</code></p></li></ul></div></li><li class="listitem"><p>EPR Propagation </p><div class="itemizedlist"><ul class="itemizedlist" type="square"><li class="listitem"><p>Using JAXB 2.1 bind W3C EPR to
                                            <code class="literal">W3CEndpointReference</code> class</p></li><li class="listitem"><p>Marshall/Unmarshall
                                            <code class="literal">W3CEndpointReference</code> class using
                                            JAXB</p></li></ul></div></li></ul></div></li><li class="listitem"><p>User friendly APIs to enable/disable features, such
                    as MTOM and Addressing</p></li></ul></div><p>JAX-RPC users should note that JAX-WS is a completely
            different technology than JAX-RPC and thus cannot run JAX-RPC
            applications on top of JAX-WS. If you have an existing JAX-RPC
            application it must be converted to work with JAX-WS.</p></div><div class="section" title="1.2.2.&nbsp;Fully Dynamic Runtime"><div class="titlepage"><div><div><h4 class="title" id="fully-dynamic-runtime">1.2.2.&nbsp;Fully Dynamic Runtime</h4></div></div></div><p>In JAX-WS, all artifacts generated by
            <span class="command"><strong>apt</strong></span>, <span class="command"><strong>wsimport</strong></span> and
            <span class="command"><strong>wsgen</strong></span> are portable. JAX-WS uses the annotations
            within the SEI to aid in marshalling/unmarshalling messages.
            Because we no longer generated non-portable artifacts, we were
            able to get rid of tools like JAX-RPC's
            <span class="command"><strong>wsdeploy</strong></span>. The user now can create their own
            deployable WAR file. To learn more about creating a WAR file and
            the deployment descriptor, see <a class="xref" href="ch03.html#users-guide-war-file-packaging" title="15.&nbsp;WAR File Packaging">WAR File Packaging</a>. It should also be noted that
            JAX-RPC's <span class="command"><strong>wscompile</strong></span> tool has been replaced by
            two new tools: <span class="command"><strong>wsimport</strong></span> and
            <span class="command"><strong>wsgen</strong></span>. <span class="command"><strong>wsimport</strong></span> is used for
            importing WSDLs and generating the portable artifacts.
            <span class="command"><strong>wsgen</strong></span> processes a compiled SEI and generates
            the portable artifacts. Unlike JAX-RPC's
            <span class="command"><strong>wscompile</strong></span> JAX-WS's <span class="command"><strong>wsgen</strong></span>
            does not generate WSDL at tool-time, the WSDL is now generated
            when the endpoint is deployed. There however is an option on
            <span class="command"><strong>wsgen</strong></span> to generate the WSDL for developement
            purposes.</p></div><div class="section" title="1.2.3.&nbsp;MTOM &amp; swaRef"><div class="titlepage"><div><div><h4 class="title" id="mtom-amp-swaref">1.2.3.&nbsp;MTOM &amp; swaRef</h4></div></div></div><p>MTOM and swaRef support was added in JAX-WS 2.0 RI FCS
            release. MTOM and swaref support is required by the JAX-WS 2.0
            specification. This means that the MTOM or swaref solution
            developed with JAX-WS RI will be fully portable
            with any JAX-WS 2.0 compliant implementation.</p><p>MTOM implementation was completely re-written to allow
            streaming attachment support and just like rest of the
            JAX-WS RI runtime its written for better
            performance. This implementation was released as part of JAX-WS
            2.0.1 M1 release.</p><p>JAX-WS 2.2 brings in support for
            optimized transmission of binary data as specified by <a class="link" href="http://www.w3.org/TR/soap12-mtom/" target="_top">MTOM</a> (SOAP
            Message Transmission Optimization Mechanism)/ <a class="link" href="http://www.w3.org/TR/xop10/" target="_top">XOP</a> (XML Binary
            Optimized Packaing) and <a class="link" href="http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html#Referencing_Attachments_from_the_SOAP_Envelope" target="_top">swaRef</a>
            (SOAP Attachment References specified by WS-I Attachment Profile
            1.0).</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>MTOM allows optimized transmission of binary data -
                    any <code class="literal">xs:base64Binary</code> or
                    <code class="literal">xs:hexBinary</code> schema type can be send as
                    attachment following rules defined by XOP encoding and
                    MTOM specification.</p></li></ul></div><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>In swaRef, an XML element of <a class="link" href="http://ws-i.org/profiles/basic/1.1/xsd/" target="_top"><code class="literal">wsi:swaRef</code></a>
                    type (defined by WS-I Attachment Profile 1.0) is send as
                    attachment and a referenced based on CID URL schema is put
                    in place of the content of the element.</p></li></ul></div><p>For details on MTOM and swaRef features refer to <a class="xref" href="ch03.html#users-guide-mtom-and-swaref" title="7.&nbsp;MTOM and Swaref">MTOM and Swaref</a>.</p></div><div class="section" title="1.2.4.&nbsp;SOAP 1.2"><div class="titlepage"><div><div><h4 class="title" id="soap-1-2">1.2.4.&nbsp;SOAP 1.2</h4></div></div></div><p>SOAP 1.2 support is added to JAX-WS
            2.2. For details refer to <a class="xref" href="ch03.html#users-guide-soap-1-2" title="8.&nbsp;SOAP 1.2">SOAP 1.2</a>.</p></div><div class="section" title="1.2.5.&nbsp;XML/HTTP Binding"><div class="titlepage"><div><div><h4 class="title" id="xml-http-binding">1.2.5.&nbsp;XML/HTTP Binding</h4></div></div></div><p>Support for XML/HTTP binding is added to JAX-WS 2.0. One can
            directly send XML over HTTP using <a class="xref" href="ch03.html#users-guide-provider" title="2.&nbsp;Provider">Provider</a> and
            <a class="xref" href="ch03.html#users-guide-dispatch" title="4.&nbsp;Dispatch">Dispatch</a>
            implementations. This enables support for REST style Web Services
            in JAX-WS. For details refer to restful sample.</p></div><div class="section" title="1.2.6.&nbsp;JAXB 2.2"><div class="titlepage"><div><div><h4 class="title" id="jaxb-2-0">1.2.6.&nbsp;JAXB 2.2</h4></div></div></div><p>JAX-WS RI 2.2.7 uses JAXB 2.2 for data-binding between
            Java and XML which enables features such as separate compilation,
            type substitution and other improvements.</p><div class="section" title="1.2.6.1.&nbsp;Type Substitution using @XmlSeeAlso"><div class="titlepage"><div><div><h5 class="title" id="type-substitution">1.2.6.1.&nbsp;Type Substitution using
                <code class="literal">@XmlSeeAlso</code></h5></div></div></div><p>JAXB 2.1 defines <code class="literal">@XmlSeeAlso</code>
                annotation which can be used to tell JAXB to use the classes
                mentioned with this annotation. This allows type substitution
                to takes place. See the <a class="link" href="../samples/type_substitution/src/type_substitution/server/CarDealer.java" target="_top">sample</a>
                that demonstrates it.</p><p><span class="command"><strong>wsimport</strong></span> tool, generates
                <code class="literal">@XmlSeeAlso</code> with all the classes that are
                not directly referenced by the WSDL operations. To capture all
                such classes <span class="command"><strong>wsimport</strong></span> generates
                <code class="literal">@XmlSeeAlso(ObjectFactory.class)</code> on the
                generated Service Endpoint Interface.</p></div><div class="section" title="1.2.6.2.&nbsp;@XmlElement on web service SEI parameters"><div class="titlepage"><div><div><h5 class="title" id="xmlelement-on-sei-parameters">1.2.6.2.&nbsp;<code class="literal">@XmlElement</code> on web service SEI
                parameters</h5></div></div></div><p>JAX-WS 2.2 spec allows <code class="literal">@XmlElement</code> on
                web service SEI parameters, which enables better control of
                XML representation. For this support, JAX-WS relies on JAXB
                2.2 API which allows the <code class="literal">@XmlElement</code>
                annotation on parameters.</p></div></div><div class="section" title="1.2.7.&nbsp;WS-Addressing"><div class="titlepage"><div><div><h4 class="title" id="ws-addressing">1.2.7.&nbsp;WS-Addressing</h4></div></div></div><p>JAX-WS RI 2.2.7 supports for W3C <a class="link" href="http://www.w3.org/TR/ws-addr-core" target="_top">Core</a>, <a class="link" href="http://www.w3.org/TR/ws-addr-soap" target="_top">SOAP Binding</a>
            and <a class="link" href="http://www.w3.org/TR/2007/REC-ws-addr-metadata-20070904" target="_top">Addressing
            1.0 - Metadata</a> specifications and defines standard API and
            annotations to enable/disable W3C WS-Addressing on the client and
            service endpoint. In addition to that, JAX-WS RI also supports
            <a class="link" href="http://www.w3.org/Submission/ws-addressing/" target="_top">Member
            Submission</a> version of WS-Addressing. The member submission
            version is supported in an implementation specific way. For
            compatility with JAX-WS 2.1 behavior, JAX-WS RI 2.2 also supports
            wsdls conforming to <a class="link" href="http://www.w3.org/TR/ws-addr-wsdl" target="_top">WSDL Binding</a>
            specification.</p><p>Refer to <a class="xref" href="ch03.html#users-guide-ws-addressing" title="12.&nbsp;WS-Addressing">WS-Addressing</a> for more details. See WS-Addressing
            samples <span class="bold"><strong>fromjava-wsaddressing</strong></span>,
            <span class="bold"><strong>fromwsdl-wsaddressing-policy</strong></span> and
            <span class="bold"><strong>fromwsdl-wsaddressing</strong></span> with the
            JAX-WS RI 2.2.7 for details on the WS-Addressing programming
            model.</p></div><div class="section" title="1.2.8.&nbsp;Annotations"><div class="titlepage"><div><div><h4 class="title" id="annotations">1.2.8.&nbsp;Annotations</h4></div></div></div><p>JAX-WS 2.2 relies heavily on the
            use of annotations as provided by <span class="emphasis"><em>A Metadata Facility
            for the Java Programming Language</em></span> <a class="link" href="http://jcp.org/en/jsr/detail?id=175" target="_top">(JSR 175)</a>
            and and <span class="emphasis"><em>Web Services Metadata for the Java
            Platform</em></span> <a class="link" href="http://jcp.org/en/jsr/detail?id=181." target="_top">(JSR 181)</a>
            as well as additional annotations defined by JAX-WS
            2.2. These annotations are used to
            customize the mapping from Java to XML schema/WSDL and are used at
            runtime to alleviate the need for non-portable
            serializers/deserializers that were generated in JAX-RPC
            1.x.</p><p>The JAX-WS RI utilizes an
            <span class="command"><strong>apt</strong></span> (annotation processing tool) that was
            introduced in J2SDK 5.0. <span class="command"><strong>apt</strong></span> allows the SI to
            process Java source files directly to generate the portable
            artifacts specified by the JAX-WS 2.0 specification.
            <span class="command"><strong>apt</strong></span> will be covered in more detail in section
            <a class="xref" href="ch04.html#tools-apt" title="6.&nbsp;apt">6</a>.</p><p>For more information on the annotations used by JAX-WS 2.0
            please refer to <a class="xref" href="ch03.html#users-guide-annotations" title="10.&nbsp;Annotations">Annotations</a>.</p></div><div class="section" title="1.2.9.&nbsp;Customizations"><div class="titlepage"><div><div><h4 class="title" id="customizations">1.2.9.&nbsp;Customizations</h4></div></div></div><p>JAX-WS RI 2.2.7 carries forward customization support
            introduced in JAX-WS 2.0 RI.</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Define a package where Java artifacts mapped from a
                    WSDL file will be generated</p></li><li class="listitem"><p>Package customization for value classes mapped from
                    the imported XML schemas by the WSDL document</p></li><li class="listitem"><p>Handler chain customization</p></li></ul></div><p>JAX-WS 2.0 specification defines standard XML based
            customization for a WSDL file to Java mapping and to control
            certain features. These customizations, or <span class="emphasis"><em>binding
            declarations,</em></span> can customize almost all WSDL components
            that can be mapped to Java, such as the service endpoint interface
            class, method name, parameter name, exception class, etc. The
            other important thing you can do with these binding declarations
            is to control certain features, such as asynchrony, provider,
            wrapper style, and additional headers. For example, a client
            application can enable asynchrony for a particular operation in a
            portType, all operations in a <code class="literal">portType</code>, or all
            <code class="literal">portType</code> operations defined in the WSDL
            file.</p><p>These binding declarations can be inlined in a WSDL file or
            can live outside as an external file. The binding declarations
            closely align with the JAXB binding declarations. An application
            importing a WSDL file can inline JAXB bindings inside JAX-WS
            binding declarations to customize the inlined schema declared in
            the WSDL file. Schema files that are imported from a WSDL file can
            be customized using JAXB binding files and can be passed to
            <span class="command"><strong>wscompile</strong></span> using the <code class="option">-b</code> option
            switch.</p><p>These are the main customization features:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Scoped binding declarations. An XPath expression is
                    used to specify the target node of the WSDL file on which
                    customization should be applied.</p></li><li class="listitem"><p>Close alignment with JAXB bindings. JAXB binding
                    declarations can be inlined in an external JAX-WS binding
                    file.</p></li><li class="listitem"><p>Feature Control. Features such as asynchrony,
                    wrapper style, additional header mapping, and provider
                    interfaces can be enabled or disabled.</p></li><li class="listitem"><p>Handler chain customization (not yet specified by
                    the 2.0 specification)</p></li></ul></div><p>The following WSDL component's mapped Java names can be
            modified:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>generated service endpoint interface class</p></li><li class="listitem"><p>method</p></li><li class="listitem"><p>method parameter</p></li><li class="listitem"><p>generated exception class (for WSDL fault and header
                    fault exceptions)</p></li><li class="listitem"><p>header parameter</p></li><li class="listitem"><p>generated service class</p></li><li class="listitem"><p>port accessor methods in the generated service
                    class</p></li></ul></div><p>XML Schema Java mapping can be customized using standard
            JAXB customizations.</p><p>For more information on the customizations used by JAX-WS
            2.0 please refer to <a class="xref" href="ch03.html#users-guide-wsdl-customization" title="9.&nbsp;WSDL Customization">WSDL Customization</a>.</p></div><div class="section" title="1.2.10.&nbsp;Improved Handler Framework"><div class="titlepage"><div><div><h4 class="title" id="improved-handler-framework">1.2.10.&nbsp;Improved Handler Framework</h4></div></div></div><p>JAX-WS 2.0 specification defines two types of handlers:
            logical and protocol handlers. While protocol handlers have access
            to an entire message such as a SOAP message, logical handlers deal
            only with the payload of a message and are independent of the
            protocol being used. Handler chains can now be configured on a
            per-port, per-protocol, or per-service basis. A new framework of
            context objects has been added to allow client code to share
            information easily with handlers.</p><p>For more information on the handler framework in
            JAX-WS RI 2.2.7 please refer to <a class="xref" href="ch03.html#users-guide-handler" title="6.&nbsp;Handler">Handler</a>.</p></div><div class="section" title="1.2.11.&nbsp;Provider"><div class="titlepage"><div><div><h4 class="title" id="provider">1.2.11.&nbsp;Provider</h4></div></div></div><p>Web service endpoints may choose to work at the XML message
            level by implementing the <code class="literal">Provider</code> interface.
            Here the endpoints access messages or message payloads using this
            low level, generic API.</p><p>For more information on providers in JAX-WS RI 2.2.7
            please refer to <a class="xref" href="ch03.html#users-guide-provider" title="2.&nbsp;Provider">Provider</a>.</p></div><div class="section" title="1.2.12.&nbsp;Dispatch"><div class="titlepage"><div><div><h4 class="title" id="dispatch">1.2.12.&nbsp;Dispatch</h4></div></div></div><p>The Dispatch API is intended for advanced XML developers who
            prefer to use XML constructs at the
            <code class="literal">java.lang.transform.Source</code> or
            <code class="literal">javax.xml.soap.SOAPMessage</code> level. For added
            convenience use of the <code class="literal">Dispatch</code> API with JAXB
            data-bound objects is supported. The <code class="literal">Dispatch</code>
            API can be used in both <code class="literal">Message</code> and
            <code class="literal">Payload</code> modes.</p><p>For more information on the <code class="literal">Dispatch</code>&nbsp;
            please refer to <a class="xref" href="ch03.html#users-guide-dispatch" title="4.&nbsp;Dispatch">Dispatch</a>.</p></div><div class="section" title="1.2.13.&nbsp;Asynchronous Client Operations"><div class="titlepage"><div><div><h4 class="title" id="asynchronous-client-operations">1.2.13.&nbsp;Asynchronous Client Operations</h4></div></div></div><p>For more information on asynchronous clients in
            JAX-WS RI 2.2.7 please refer to <a class="xref" href="ch03.html#users-guide-asynchronous-client" title="5.&nbsp;Asynchronous Client">Asynchronous Client</a>.</p></div></div><div class="section" title="1.3.&nbsp;Programming Model"><div class="titlepage"><div><div><h3 class="title" id="programming-model">1.3.&nbsp;Programming Model</h3></div></div></div><p>This section of the documentation will focus on the programming
        model for both developing and publishing a web service endpoint, and
        writing a web service client. A web service endpoint is the
        implementation of a web service. A web service client is an
        application that accesses a web service.</p><div class="section" title="1.3.1.&nbsp;Server"><div class="titlepage"><div><div><h4 class="title" id="server">1.3.1.&nbsp;Server</h4></div></div></div><p>When developing a web service endpoint, a developer may
            either start from a Java endpoint implementation class or from a
            WSDL file. A WSDL (Web Services Description Language) document
            describes the contract between the web service endpoint and the
            client. A WSDL document may include and/or import XML schema files
            used to describe the data types used by the web service. When
            starting from a Java class, the tools generate any portable
            artifacts as mandated by the spec. When starting from a WSDL file
            and schemas, the tools generate a service endpoint
            interface.</p><p>There is a trade-off when starting from a Java class or from
            a WSDL file. If you start from a Java class, you can make sure
            that the endpoint implementation class has the desirable Java data
            types, but the developer has less control of the generated XML
            schema. When starting from a WSDL file and schema, the developer
            has total control over what XML schema is used, but has less
            control over what the generated service endpoint and the classes
            it uses will contain.</p><div class="section" title="1.3.1.1.&nbsp;Starting from Java"><div class="titlepage"><div><div><h5 class="title" id="starting-from-java">1.3.1.1.&nbsp;Starting from Java</h5></div></div></div><p>The basic process for deploying a web service from a
                Java class consists of two steps.</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Generate portable artifacts.</p></li><li class="listitem"><p>Create a WAR file to deploy</p></li></ol></div></div><div class="section" title="1.3.1.2.&nbsp;Generate Portable Artifacts"><div class="titlepage"><div><div><h5 class="title" id="generate-portable-artifacts">1.3.1.2.&nbsp;Generate Portable Artifacts</h5></div></div></div><p>Portable artifacts generated by JAX-WS RI 2.2.7
                include zero or more JavaBean classes to aide in the
                marshaling of method invocations and responses, as well as
                service-specific exceptions.</p><p>In document/literal wrapped mode, two JavaBeans are
                generated for each operation in the web service. One bean is
                for invoking the other for the response. In all modes
                (rpc/literal and both document/literal modes), one JavaBean is
                generated for each service-specific exception.</p><p>When starting from Java the developer must provide the
                JAX-WS tools with a valid endpoint implementation class. This
                implementation class is the class that implements the desired
                web service. JAX-WS has a number of restrictions on endpoint
                implementation classes. A valid endpoint implementation class
                must meet the following requirements:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>It <span class="emphasis"><em>must</em></span> carry a
                        javax.jws.WebService annotation (see JSR 181).</p></li><li class="listitem"><p>Any of its methods <span class="emphasis"><em>may</em></span>
                        carry a javax.jws.WebMethod annotation (see
                        7.5.2).</p></li><li class="listitem"><p>All of its methods <span class="emphasis"><em>may</em></span>
                        throw java.rmi.RemoteException in addition to any
                        service-specific exceptions.</p></li><li class="listitem"><p>All method parameters and return types
                        <span class="emphasis"><em>must</em></span> be compatible with the JAXB
                        2.0 Java to XML Schema mapping definition.</p></li><li class="listitem"><p>A method parameter or return value type
                        <span class="emphasis"><em>must not</em></span> implement the
                        java.rmi.Remote interface either directly or
                        indirectly.</p></li></ul></div><p>Here is an example of a a simple endpoint implementation
                class <code class="code"> <a class="link" href="../samples/fromjava/src/fromjava/server/AddNumbersImpl.java" target="_top">AddNumbersImpl.java</a>
                </code> from the <span class="application">fromjava</span>
                sample:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">package</span> fromjava.server;

<span class="ReservedWord">import</span> javax.jws.WebService;

<span class="Annotation">@WebService</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl {
    <span class="Comment">/**
     * @param number1
     * @param number2
     * @return The sum
     * @throws AddNumbersException if any of the numbers to be added is 
     * negative.
     */</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            AddNumbersException {
        <span class="ReservedWord">if</span> (number1 &lt; <span class="Numeric">0</span> || number2 &lt; <span class="Numeric">0</span>) {
            <span class="ReservedWord">throw</span> <span class="ReservedWord">new</span> AddNumbersException(<span class="String">"Negative number cant be "</span> +
                    <span class="String">"added!"</span>, <span class="String">"Numbers: "</span> + number1 + <span class="String">", "</span> + number2);
        }
        <span class="ReservedWord">return</span> number1 + number2;
    }
}</pre></div><p>If you are familiar with JAX-RPC 1.1, you will notice
                that this implementation class does not implement a service
                endpoint interface. In JAX-WS RI 2.2.7 a service
                endpoint interface is no longer required.</p><p>When starting from a Java endpoint implementation class,
                it is recommended that the portable artifacts be generated
                from source using <span class="command"><strong>apt</strong></span>. This because the
                JAX-WS tools will then have full access to the source code and
                will be able to utilize parameter names that are otherwise not
                available through the Java reflection APIs. If the source for
                the endpoint implementation class is not available, the
                portable artifacts can be generated using
                <span class="command"><strong>wscompile</strong></span>. Here is a sample
                <span class="command"><strong>apt</strong></span> Ant task from the samples:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;apt</span>
        <span class="Identifier">debug</span>=<span class="String">"${debug}"</span>
        <span class="Identifier">verbose</span>=<span class="String">"${verbose}"</span>
        <span class="Identifier">destdir</span>=<span class="String">"${build.classes.home}"</span>
        <span class="Identifier">sourcedestdir</span>=<span class="String">"${build.classes.home}"</span>
        <span class="Identifier">sourcepath</span>=<span class="String">"${basedir}/src"</span><span class="ReservedWord">&gt;</span>
    
    <span class="ReservedWord">&lt;classpath</span> <span class="Identifier">refid</span>=<span class="String">"jax-ws.classpath"</span><span class="ReservedWord">/&gt;</span>
    <span class="ReservedWord">&lt;option</span> <span class="Identifier">key</span>=<span class="String">"r"</span> <span class="Identifier">value</span>=<span class="String">"${build.home}"</span><span class="ReservedWord">/&gt;</span>
    <span class="ReservedWord">&lt;source</span> <span class="Identifier">dir</span>=<span class="String">"${basedir}/src"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;include</span> <span class="Identifier">name</span>=<span class="String">"**/server/*.java"</span><span class="ReservedWord">/&gt;</span>
    <span class="ReservedWord">&lt;/source&gt;</span>
<span class="ReservedWord">&lt;/apt&gt;</span></pre></div><p>More information about the <span class="command"><strong>apt</strong></span> Ant
                task can be found <a class="xref" href="ch04.html#tools-apt" title="6.&nbsp;apt"><span class="command"><strong>apt</strong></span></a>. If this task is run on the
                fromjava sample, the output would include:</p><div class="informalexample"><pre class="programlisting">AddNumbers.class
AddNumbers.java
AddNumbersExceptionBean.class
AddNumbersExceptionBean.java
AddNumbersResponse.class
AddNumbersResponse.java</pre></div><p>The <code class="filename">AddNumbersImplService.wsdl</code> file
                describes the web service. The
                <code class="filename">schema1.xsd</code> file is imported by the
                <code class="filename">AddNumbersImplService.wsdl</code> and contains
                the datatypes used by the web service. The
                <code class="filename">AddNumbers.class</code>/<code class="filename">AddNumbers.java</code>
                files contain the a bean used by a JAXB to marshall/unmarshall
                the <code class="literal">addNumbers</code> request. The
                <code class="filename">AddNumbersExceptionBean.class</code>/<code class="filename">AddNumbersExceptionBean.java</code>
                file is a bean used by JAXB to marshall the contents of the
                <code class="literal">AddNumbersException</code> class. The
                <code class="filename">AddNumbersResponse.class</code>/<code class="filename">AddNumbersResponse.java</code>
                files represent the response bean used by JAXB to
                marshall/unmarshall the <code class="literal">addNumbers</code>
                response.</p></div><div class="section" title="1.3.1.3.&nbsp;Create a WAR file to deploy"><div class="titlepage"><div><div><h5 class="title" id="create-a-war-file-to-deploy">1.3.1.3.&nbsp;Create a WAR file to deploy</h5></div></div></div><p>Creating a WAR file is nothing more than packaging the
                service endpoint interface (if there is one), service endpoint
                implementation, Java classes used by the endpoint
                implementation and a deployment descriptor in WAR format. For
                the fromjava sample the <code class="literal">AddNumbersImpl</code> and
                <code class="literal">AddNumbersException</code> classes in the
                <span class="package">fromjava.server</span> package, and the deployment
                descriptor are bundled together to make a raw WAR file. To
                learn more about creating a WAR file and the deployment
                descriptor, see <a class="xref" href="ch03.html#users-guide-war-file-packaging" title="15.&nbsp;WAR File Packaging">WAR File Packaging</a>. The deployment descriptor used in
                <span class="application">fromjava</span> sample is given below and
                can be found <a class="link" href="../samples/fromjava/etc/sun-jaxws.xml" target="_top">here</a>:</p><div class="informalexample"><pre class="programlisting"><span class="hl-directive" style="color: maroon">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="ReservedWord">&lt;endpoints</span> <span class="Identifier">xmlns</span>=<span class="String">'http://java.sun.com/xml/ns/jax-ws/ri/runtime'</span>
        <span class="Identifier">version</span>=<span class="String">'2.0'</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;endpoint</span> <span class="Identifier">name</span>=<span class="String">'fromjava'</span>
            <span class="Identifier">implementation</span>=<span class="String">'fromjava.server.AddNumbersImpl'</span>
            <span class="Identifier">url-pattern</span>=<span class="String">'/addnumbers'</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;/endpoints&gt;</span></pre></div><p>The attributes of the
                <code class="literal">&lt;endpoint&gt;</code> element are described
                below:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>name is simply an identifier for this
                        endpoint</p></li><li class="listitem"><p>implementation is used to specify the endpoint
                        implementation class</p></li><li class="listitem"><p>urlpattern is used to URL pattern used to access
                        this endpoint.</p></li></ul></div><p>The structure of the raw WAR file is shown below:</p><div class="informalexample"><pre class="programlisting">META-INF/MANIFEST.MF
WEB-INF/sun-jaxws.xml
WEB-INF/web.xml
WEB-INF/classes/fromjava/server/AddNumbersException.class
WEB-INF/classes/fromjava/server/AddNumbersImpl.class
WEB-INF/classes/fromjava/server/jaxws/AddNumbers.class
WEB-INF/classes/fromjava/server/jaxws/AddNumbersExceptionBean.class
WEB-INF/classes/fromjava/server/jaxws/AddNumbersResponse.class</pre></div><p>The WAR file created can now be published on a
                JAX-WS RI enabled servlet container such as
                the <a class="link" href="http://java.sun.com/j2ee/1.4/download.html" target="_top">Sun
                Java System Application Server Platform Edition
                8.2</a></p></div><div class="section" title="1.3.1.4.&nbsp;Starting from a WSDL File"><div class="titlepage"><div><div><h5 class="title" id="starting-from-a-wsdl-file">1.3.1.4.&nbsp;Starting from a WSDL File</h5></div></div></div><p>The basic process for deploying a web service when
                starting from a WSDL document consists of the following four
                steps:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Generate a service endpoint interface.</p></li><li class="listitem"><p>Implement the service endpoint interface.</p></li><li class="listitem"><p>Create a WAR file to deploy.</p></li></ol></div></div><div class="section" title="1.3.1.5.&nbsp;Generate a Service Endpoint Interface"><div class="titlepage"><div><div><h5 class="title" id="generate-a-service-endpoint-interface">1.3.1.5.&nbsp;Generate a Service Endpoint Interface</h5></div></div></div><p>This step involves compiling or importing the WSDL file
                to generate a service endpoint interface and value classes
                mapped from imported XML schemas.</p><p>Below is a sample <span class="command"><strong>wsimport</strong></span> Ant
                target:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;wsimport</span>
        <span class="Identifier">debug</span>=<span class="String">"${debug}"</span>
        <span class="Identifier">verbose</span>=<span class="String">"${verbose}"</span>
        <span class="Identifier">keep</span>=<span class="String">"${keep}"</span>
        <span class="Identifier">destdir</span>=<span class="String">"${build.classes.home}"</span>
        <span class="Identifier">wsdl</span>=<span class="String">"${server.wsdl}"</span><span class="ReservedWord">&gt;</span>
    
    <span class="ReservedWord">&lt;binding</span> <span class="Identifier">dir</span>=<span class="String">"${basedir}/etc"</span>
            <span class="Identifier">includes</span>=<span class="String">"${server.binding}"</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;/wsimport&gt;</span></pre></div><p>Its commandline equivalent is:</p><div class="informalexample"><pre class="programlisting">wsimport.sh etc/AddNumbers.wsdl -b custom-server.xml</pre></div><p>Lets look at the excerpt of <a class="link" href="../samples/fromwsdl/etc/AddNumbers.wsdl" target="_top">AddNumbers.wsdl</a>
                from the sample <span class="application">fromwsdl</span>:</p><p>The generated service endpoint interface looks as
                follows:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">package</span> fromwsdl.server;

<span class="Annotation">@javax.jws.WebService(
        name = "AddNumbersPortType",
        serviceName = "AddNumbersService",
        targetNamespace = "http://duke.example.org")</span>
<span class="Annotation">@javax.jws.soap.SOAPBinding(
        style = javax.jws.soap.SOAPBinding.Style.DOCUMENT,
        use = javax.jws.soap.SOAPBinding.Use.LITERAL,
        parameterStyle = javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED)</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">interface</span> AddNumbersPortType <span class="ReservedWord">extends</span> java.rmi.Remote {
    <span class="Annotation">@javax.jws.WebMethod(operationName = "addNumbers")</span>
    <span class="Annotation">@javax.jws.WebResult(name = "return")</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="Annotation">@javax.jws.WebParam(name = "arg0")</span> <span class="ReservedWord">int</span> arg0, 
                          <span class="Annotation">@javax.jws.WebParam(name = "arg1")</span> <span class="ReservedWord">int</span> arg1) 
            <span class="ReservedWord">throws</span> fromwsdl.server.AddNumbersFault_Exception, java.rmi.RemoteException;
}</pre></div><p>The generated service endpoint interface has annotations
                that can be used by the future versions of JAX-WS 2.0 to do
                dynamic binding and serialization/deserialization at runtime.
                Alternatively this service endpoint interface can be used to
                generate a WSDL and schema file. Please note that
                round-tripping is not guaranteed in this case. So the
                generated WSDL file and schema may not be the same as the one
                the service endpoint interface was generated from.</p></div><div class="section" title="1.3.1.6.&nbsp;Implement the Service Endpoint Interface"><div class="titlepage"><div><div><h5 class="title" id="implement-the-service-endpoint-interface">1.3.1.6.&nbsp;Implement the Service Endpoint Interface</h5></div></div></div><p>The next thing to do will be to provide the
                implementation of the service endpoint interface generated in
                the previous step. When you implement the service endpoint
                interface it is necessary to provide a
                <code class="literal">@WebService</code> annotation on the
                implementation class with a endpointInteface element
                specifying the qualified name of the endpoint interface class.
                Let's look at the implementation class <a class="link" href="../samples/fromwsdl/src/fromwsdl/server/AddNumbersImpl.java" target="_top">fromwsdl.server.AddNumbersImpl.java</a>
                from the sample application
                <span class="application">fromwsdl</span>:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">package</span> fromwsdl.server;

<span class="Annotation">@WebService(endpointInterface = "fromwsdl.server.AddNumbersPortType")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl <span class="ReservedWord">implements</span> AddNumbersPortType {
    <span class="Comment">/**
     * @param number1
     * @param number2
     * @return The sum
     * @throws AddNumbersException if any of the numbers to be added is 
     * negative.
     */</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            AddNumbersFault_Exception {
        ...
    }
}</pre></div></div><div class="section" title="1.3.1.7.&nbsp;Create a WAR"><div class="titlepage"><div><div><h5 class="title" id="create-a-war">1.3.1.7.&nbsp;Create a WAR</h5></div></div></div><p>This step is similar to the one described above in <a class="xref" href="ch03.html#create-a-war-file-to-deploy" title="1.3.1.3.&nbsp;Create a WAR file to deploy">Create a WAR file to deploy</a> .</p><p>Here the service endpoint interface implementation class
                from previous step, together with a deployment descriptor file
                sun-jaxws.xml, and <code class="filename">web.xml</code> should be
                bundled together with the service endpoint interface, value
                classes generated in the first step mentioned in <a class="xref" href="ch03.html#generate-a-service-endpoint-interface" title="1.3.1.5.&nbsp;Generate a Service Endpoint Interface">Generate a Service Endpoint Interface</a>.</p><p>Let's look at <a class="link" href="../samples/fromwsdl/etc/sun-jaxws.xml" target="_top">sun-jaxws.xml</a>
                from the sample application
                <span class="application">fromwsdl</span>:</p><div class="informalexample"><pre class="programlisting"><span class="hl-directive" style="color: maroon">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="ReservedWord">&lt;endpoints</span> <span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/jax-ws/ri/runtime"</span>
        <span class="Identifier">version</span>=<span class="String">"2.0"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;endpoint</span> <span class="Identifier">name</span>=<span class="String">"fromwsdl"</span>
            <span class="Identifier">interface</span>=<span class="String">"fromwsdl.server.AddNumbersPortType"</span>
            <span class="Identifier">implementation</span>=<span class="String">"fromwsdl.server.AddNumbersImpl"</span>
            <span class="Identifier">wsdl</span>=<span class="String">"WEB-INF/wsdl/AddNumbers.wsdl"</span>
            <span class="Identifier">service</span>=<span class="String">"{http://duke.example.org}AddNumbersService"</span>
            <span class="Identifier">port</span>=<span class="String">"{http://duke.example.org}AddNumbersPort"</span>
            <span class="Identifier">url-pattern</span>=<span class="String">"/addnumbers"</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;/endpoints&gt;</span></pre></div><p>It defines the deployment-related configuration
                information for the <span class="application">fromwsdl</span>
                endpoint. You will notice that this deployment descriptor
                contains additional attributes than the deployment descriptor
                described in <a class="xref" href="ch03.html#create-a-war-file-to-deploy" title="1.3.1.3.&nbsp;Create a WAR file to deploy">Create a WAR file to deploy</a>. The interface attribute
                references the service endpoint interface generated in step 1.
                The wsdl attribute also points at the WSDL that was imported
                by <span class="command"><strong>wsimport</strong></span>. The service attribute
                references which service in the WSDL this endpoint is from and
                the port is the name of the port in that service for this
                endpoint.</p><p>To learn more about creating a WAR file and the
                deployment descriptor, see <a class="xref" href="ch03.html#users-guide-war-file-packaging" title="15.&nbsp;WAR File Packaging">WAR File Packaging</a>.</p><p>The WAR file created can now be published on a
                JAX-WS RI enabled servlet container such as
                the <a class="link" href="http://java.sun.com/j2ee/1.4/download.html" target="_top">Sun
                Java System Application Server Platform Edition
                8.2</a></p></div><div class="section" title="1.3.1.8.&nbsp;J2SE Endpoints"><div class="titlepage"><div><div><h5 class="title" id="j2se-endpoints">1.3.1.8.&nbsp;J2SE Endpoints</h5></div></div></div><p>Endpoints can be created and published programmatically
                using <code class="literal">javax.xml.ws.Endpoint</code> API in J2SE. To
                learn more about these endpoints, see <a class="xref" href="ch03.html#users-guide-endpoint-api" title="17.&nbsp;Endpoint API">Endpoint API</a>.</p></div></div><div class="section" title="1.3.2.&nbsp;Client"><div class="titlepage"><div><div><h4 class="title" id="client">1.3.2.&nbsp;Client</h4></div></div></div><p>A client application can access a remote web service
            endpoint in one of two ways: port and dispatch.</p><div class="section" title="1.3.2.1.&nbsp;Dynamic Proxy"><div class="titlepage"><div><div><h5 class="title" id="dynamic-proxy">1.3.2.1.&nbsp;Dynamic Proxy</h5></div></div></div><p>In this approach client side invokes Web services via a
                dynamic proxy. The proxies for the Web Service are created
                from the generated Service and service endpoint interfaces.
                Once the proxies are created. the client application can
                invoke methods on those proxies just like a standard
                implementation of those interfaces. The sections below
                describe this process more detail.</p></div><div class="section" title="1.3.2.2.&nbsp;Generate Client Artifacts"><div class="titlepage"><div><div><h5 class="title" id="generate-client-artifacts">1.3.2.2.&nbsp;Generate Client Artifacts</h5></div></div></div><p>The <span class="command"><strong>wsimport</strong></span> tool is used to generate
                the service endpoint interface and the service interface
                classes. Below is the sample <span class="command"><strong>wsimport</strong></span> Ant
                target:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;wsimport</span>
        <span class="Identifier">debug</span>=<span class="String">"${debug}"</span>
        <span class="Identifier">verbose</span>=<span class="String">"${verbose}"</span>
        <span class="Identifier">keep</span>=<span class="String">"${keep}"</span>
        <span class="Identifier">destdir</span>=<span class="String">"${build.classes.home}"</span>
        <span class="Identifier">wsdl</span>=<span class="String">"${client.wsdl}"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;classpath&gt;</span>
        <span class="ReservedWord">&lt;path</span> <span class="Identifier">refid</span>=<span class="String">"jax-ws.classpath"</span><span class="ReservedWord">/&gt;</span>
        <span class="ReservedWord">&lt;pathelement</span> <span class="Identifier">location</span>=<span class="String">"${build.classes.home}"</span><span class="ReservedWord">/&gt;</span>
    <span class="ReservedWord">&lt;/classpath&gt;</span>
    <span class="ReservedWord">&lt;binding</span> <span class="Identifier">dir</span>=<span class="String">"${basedir}/etc"</span> <span class="Identifier">includes</span>=<span class="String">"${client.binding}"</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;/wsimport&gt;</span></pre></div><p>The command line equivalent of this Ant target
                is:</p><div class="informalexample"><pre class="programlisting">wsimport.sh -classpath client_classpath -d dest_dir -s src_dir \
    -b custom-client.xml http://localhost:8080/jax-ws-fromwsdl/addnumbers?WSDL</pre></div><p>For more details see the <a class="xref" href="ch04.html#tools-wsimport" title="2.&nbsp;wsimport"><span class="command"><strong>wsimport</strong></span></a> documentation.</p><p>Here is the excerpt from <a class="link" href="../samples/fromwsdl/src/fromwsdl/client/AddNumbersClient.java" target="_top">fromwsdl.client.AddNumbersClient.java</a>
                in the <span class="application">fromjava</span> sample
                application:</p><div class="informalexample"><pre class="programlisting"><span class="Comment">//get the port</span>
AddNumbersPortType port = <span class="ReservedWord">new</span> AddNumbersService().getAddNumbersPort();

<span class="Comment">//invoke the remote method</span>
<span class="ReservedWord">int</span> result = port.addNumbers(<span class="Numeric">10</span>, <span class="Numeric">20</span>);</pre></div></div><div class="section" title="1.3.2.3.&nbsp;Dispatch"><div class="titlepage"><div><div><h5 class="title" id="dispatch-1">1.3.2.3.&nbsp;Dispatch</h5></div></div></div><p>The <code class="literal">Dispatch</code> API is intended for
                advanced XML developers who prefer using XML constructs at the
                <code class="literal">java.lang.transform.Source</code> or
                <code class="literal">javax.xml.soap.SOAPMessage</code> level. For added
                convenience use of <code class="literal">Dispatch</code> with JAXB data
                binding object is supported. With the
                <code class="literal">XML/HTTP</code> binding a
                <code class="literal">javax.activation.DataSource</code> can also be
                used. The <code class="literal">Dispatch</code> APIs can be used in both
                <code class="literal">Message</code> and <code class="literal">Payload</code>
                modes. The <code class="literal">Dispatch</code> API client with an
                <code class="literal">XML/HTTP</code> binding can be used with REST Web
                Services. Please see the restful sample program for more
                information.</p><p>For more information on <code class="literal">Dispatch</code> in
                JAX-WS RI 2.2.7 please refer to <a class="xref" href="ch03.html#users-guide-dispatch" title="4.&nbsp;Dispatch">Dispatch</a>.</p></div></div></div><div class="section" title="1.4.&nbsp;Useful Information"><div class="titlepage"><div><div><h3 class="title" id="useful-information">1.4.&nbsp;Useful Information</h3></div></div></div><p><a class="link" href="http://docs.oracle.com/javase/6/docs/technotes/guides/apt/index.html" target="_top">Annotation
        Processing Tool (apt)</a> &#8211;
        http://docs.oracle.com/javase/6/docs/technotes/guides/apt/index.html.</p><p>Please use the <a class="link" href="http://forums.java.net/jive/forum.jspa?forumID=46&amp;start=0" target="_top">JAXB
        and JAX-WS</a> forum for feedback.</p><p>The JAX-WS project on Java.net is: <a class="link" href="http://jax-ws.java.net/" target="_top">http://jax-ws.java.net</a>.</p></div></div><div lang="en" class="section" title="2.&nbsp;Provider"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-provider">2.&nbsp;Provider</h2></div></div></div><p>Web Service endpoints may choose to work at the XML message level by
    implementing the <code class="literal">Provider</code> interface. This is achieved
    by implementing either <code class="literal">Provider&lt;Source&gt;</code> or
    <code class="literal">Provider&lt;SOAPMessage&gt;</code> or
    <code class="literal">Provider&lt;DataSource&gt;</code>. The endpoint accesses the
    message or message payload using this low-level, generic API. All the
    Provider endpoints must have <code class="literal">@WebServiceProvider</code>
    annotation. The <code class="literal">@ServiceMode</code> annotation is used to
    convey whether the endpoint wants to access the message (
    <code class="literal">Service.Mode.MESSAGE</code>) or payload (
    <code class="literal">Service.Mode.PAYLOAD</code>). If there is no
    <code class="literal">@ServiceMode</code> annotation on the endpoint, payload is the
    default value. The endpoint communicates with handlers using
    <code class="literal">WebServiceContext resource like any other normal
    endpoint</code>. Provider endpoints can start from java or WSDL. When
    the provider endpoints start from a WSDL file,
    <code class="literal">&lt;provider&gt;</code> WSDL customization can be used to mark
    a port as a provider.</p><div class="section" title="2.1.&nbsp;Provider<Source&gt; and PAYLOAD"><div class="titlepage"><div><div><h3 class="title" id="section-3091238697838234">2.1.&nbsp;<code class="literal">Provider&lt;Source&gt;</code> and
        <code class="literal">PAYLOAD</code></h3></div></div></div><p>An endpoint can access only the payload of a request using
        <code class="literal">Service.Mode.PAYLOAD</code> in the
        <code class="literal">@ServiceMode</code> annotation. This is the default
        behaviour, if the annotation is missing.</p><p>For example:</p><div class="informalexample"><pre class="programlisting"><span class="Annotation">@WebServiceProvider</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> ProviderImpl <span class="ReservedWord">implements</span> Provider&lt;Source&gt; {
    <span class="ReservedWord">public</span> Source invoke(Source source) { <span class="Comment">// do request processing Source</span>
        response = ...;
        <span class="ReservedWord">return</span> response;
    }
}</pre></div></div><div class="section" title="2.2.&nbsp;Provider<SOAPMessage&gt; and MESSAGE"><div class="titlepage"><div><div><h3 class="title" id="section-8519606736474974">2.2.&nbsp;<code class="literal">Provider&lt;SOAPMessage&gt;</code> and
        <code class="literal">MESSAGE</code></h3></div></div></div><p>An endpoint can access an entire SOAP request as a
        <code class="literal">SOAPMessage</code>.
        <code class="literal">Service.Mode.MESSAGE</code> in the
        <code class="literal">@ServiceMode</code> annotation is used to convey the
        intent.</p><p>For example:</p><div class="informalexample"><pre class="programlisting"><span class="Annotation">@WebServiceProvider</span>
<span class="Annotation">@ServiceMode(value = Service.Mode.MESSAGE)</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> ProviderImpl <span class="ReservedWord">implements</span> Provider&lt;SOAPMessage&gt; {
    <span class="ReservedWord">public</span> SOAPMessage invoke(SOAPMessage msg) { <span class="Comment">// do request processing</span>
        SOAPMessage response =...;
        <span class="ReservedWord">return</span> response;
    }
}</pre></div></div><div class="section" title="2.3.&nbsp;Provider<Source&gt; and MESSAGE"><div class="titlepage"><div><div><h3 class="title" id="section-7319353703410434">2.3.&nbsp;<code class="literal">Provider&lt;Source&gt;</code> and
        <code class="literal">MESSAGE</code></h3></div></div></div><p>An endpoint can access a request as a <code class="literal">Source</code>.
        If the request is a <code class="literal">SOAPMessage</code>, only the
        <code class="literal">SOAPPart</code> (no attachments) of the message is passed
        as <code class="literal">Source</code> to the <code class="literal">invoke</code> method.
        If the returned response is null, it is considered a one way
        MEP.</p><p>For example:</p><div class="informalexample"><pre class="programlisting"><span class="Annotation">@ServiceMode(value = Service.Mode.MESSAGE)</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> ProviderImpl <span class="ReservedWord">implements</span> Provider&lt;Source&gt; {
    <span class="ReservedWord">public</span> Source invoke(Source source) { <span class="Comment">// do request processing</span>
        using source <span class="Comment">// return null to indicate oneway return null;</span>
    }
}</pre></div></div><div class="section" title="2.4.&nbsp;WSDL Customization"><div class="titlepage"><div><div><h3 class="title" id="section-674124516240791">2.4.&nbsp;WSDL Customization</h3></div></div></div><p>If the provider endpoint starts with a WSDL file, a port can be
        customized to a provider endpoint using the
        <code class="literal">&lt;provider&gt;</code> customization.
        <span class="command"><strong>wsimport</strong></span> won't generate any artifacts for that
        port.</p><p>For example:</p><div class="informalexample"><pre class="programlisting"><span class="hl-directive" style="color: maroon">&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;</span>
<span class="ReservedWord">&lt;bindings</span>
        <span class="Identifier">...</span>
        <span class="Identifier">wsdlLocaption</span>=<span class="String">"AddNumbers.wsdl"</span><span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/jaxws"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;bindings</span> <span class="Identifier">node</span>=<span class="String">"wsdl:definitions"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;package</span> <span class="Identifier">name</span>=<span class="String">"provider.server"</span><span class="ReservedWord">/&gt;</span>
        <span class="ReservedWord">&lt;provider&gt;</span>true<span class="ReservedWord">&lt;/provider&gt;</span>
    <span class="ReservedWord">&lt;/bindings&gt;</span>
<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div></div><div class="section" title="2.5.&nbsp;The sun-jaxws.xml file"><div class="titlepage"><div><div><h3 class="title" id="section-648626808421419">2.5.&nbsp;The <code class="literal">sun-jaxws.xml</code> file</h3></div></div></div><p>The attributes of provider endpoint in sun-jaxws.xml: name,
        implementation, wsdl, service, port override the attributes provided
        through <code class="literal">@WebServiceProvider</code> annotation. For SOAP1.2
        binding, one needs to specify binding attribute.</p><p>For example:</p><div class="informalexample"><pre class="programlisting"><span class="hl-directive" style="color: maroon">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="ReservedWord">&lt;endpoints</span> <span class="Identifier">xmlns</span>=<span class="String">'http://java.sun.com/xml/ns/jax-ws/ri/runtime'</span>
        <span class="Identifier">version</span>=<span class="String">'2.0'</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;endpoint</span> <span class="Identifier">name</span>=<span class="String">'AddNumbers'</span>
            <span class="Identifier">implementation</span>=<span class="String">'provider.server.AddNumbersImpl'</span>
            <span class="Identifier">wsdl</span>=<span class="String">'WEB-INF/wsdl/AddNumbers.wsdl'</span>
            <span class="Identifier">service</span>=<span class="String">'{http://duke.example.org}AddNumbersService'</span>
            <span class="Identifier">port</span>=<span class="String">'{http://duke.example.org}AddNumbersPort'</span>
            <span class="Identifier">url-pattern</span>=<span class="String">'/addnumbers'</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;/endpoints&gt;</span></pre></div><p>If the wsdl, service, port are not specified in sun-jaxws.xml,
        then should be declared in the <code class="literal">@WebServiceProvider</code>
        annotation in implementation class.</p></div><div class="section" title="2.6.&nbsp;Provider and Binding"><div class="titlepage"><div><div><h3 class="title" id="section-343591403757231">2.6.&nbsp;Provider and Binding</h3></div></div></div><p>Provider endpoint can be configured for different bindings using
        binding ids. These binding ids are defined in JAX-WS API and endpoint
        can be configured by specifying <code class="literal">@BindingType</code>
        annotation or using binding attribute in sun-jaxws.xml. sun-jaxws.xml
        overwrites binding defined by <code class="literal">@BindingType</code>
        annotation. If the binding is not specified using
        <code class="literal">@BindingType</code> or in
        <code class="filename">sun-jaxws.xml</code>, the default binding is
        SOAP1.1/HTTP.</p><p>For example: To specify <code class="literal">XML/HTTP</code> binding
        using <code class="literal">@BindingType</code> annotation</p><div class="informalexample"><pre class="programlisting"><span class="Annotation">@ServiceMode(value = Service.Mode.MESSAGE)</span>
<span class="Annotation">@BindingType(value = HTTPBinding.HTTP_BINDING)</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> ProviderImpl <span class="ReservedWord">implements</span> Provider&lt;Source&gt; {
    <span class="ReservedWord">public</span> Source invoke(Source source) {
        <span class="Comment">// ...</span>
    }
}</pre></div><p>For example: To specify <code class="literal">XML/HTTP</code> binding in
        <code class="filename">sun-jaxws.xml</code></p><div class="informalexample"><pre class="programlisting"><span class="hl-directive" style="color: maroon">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="ReservedWord">&lt;endpoints</span> <span class="Identifier">xmlns</span>=<span class="String">'http://java.sun.com/xml/ns/jax-ws/ri/runtime'</span>
        <span class="Identifier">version</span>=<span class="String">'2.0'</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;endpoint</span>
            <span class="Identifier">...</span>
            <span class="Identifier">binding</span>=<span class="String">"http://www.w3.org/2004/08/wsdl/http"</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;/endpoints&gt;</span></pre></div></div><div class="section" title="2.7.&nbsp;RESTful Provider endpoints"><div class="titlepage"><div><div><h3 class="title" id="section-330867941262645">2.7.&nbsp;RESTful Provider endpoints</h3></div></div></div><p>RESTful Web Services can be built using
        <code class="literal">XML/HTTP</code> binding based <code class="literal">Provider</code>
        endpoints. In this case, even HTTP GET requests are passed to the
        endpoint. <code class="literal">Endpoint</code> can get necessary HTTP request
        query string and path information using standard
        <code class="literal">MessageContext.QUERY_STRING</code> and
        <code class="literal">MessageContext.PATH_INFO</code>. For more details on
        endpoint implementation, see the <a class="link" href="../samples/restful/src/restful/server/AddNumbersImpl.java" target="_top">restful</a>
        sample. If the endpoint expects GET requests to contain extra path
        after the endpoint address, then <code class="literal">url-pattern</code> should
        have "<code class="literal">/*</code>" at the end in both
        <code class="filename">sun-jaxws.xml</code> and
        <code class="filename">web.xml</code>.</p><p>For example: <code class="filename">sun-jaxws.xml</code></p><div class="informalexample"><pre class="programlisting"><span class="hl-directive" style="color: maroon">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="ReservedWord">&lt;endpoints</span> <span class="Identifier">xmlns</span>=<span class="String">'http://java.sun.com/xml/ns/jax-ws/ri/runtime'</span>
        <span class="Identifier">version</span>=<span class="String">'2.0'</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;endpoint</span>
            <span class="Identifier">...</span>
            <span class="Identifier">binding</span>=<span class="String">"http://www.w3.org/2004/08/wsdl/http"</span>
            <span class="Identifier">url-pattern</span>=<span class="String">"/addnumbers/*"</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;/endpoints&gt;</span></pre></div><p>For example: <code class="filename">web.xml</code></p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;web-app&gt;</span>
    
    ...
    
    <span class="ReservedWord">&lt;servlet-mapping&gt;</span>
        <span class="ReservedWord">&lt;servlet-name&gt;</span>provider<span class="ReservedWord">&lt;/servlet-name&gt;</span>
        <span class="ReservedWord">&lt;url-pattern&gt;</span>/addnumbers/*<span class="ReservedWord">&lt;/url-pattern&gt;</span>
    <span class="ReservedWord">&lt;/servlet-mapping&gt;</span>
    
    ...
    
<span class="ReservedWord">&lt;/web-app&gt;</span></pre></div></div><div class="section" title="2.8.&nbsp;Provider and Handlers"><div class="titlepage"><div><div><h3 class="title" id="section-017933327977469">2.8.&nbsp;Provider and Handlers</h3></div></div></div><p>Handlers can be configured with Provider endpoints in
        <code class="filename">sun-jaxws.xml</code> descriptor or by putting
        <code class="literal">@HandlerChain</code> on the <code class="literal">Provider</code>
        implementation. For more information, see <a class="link" href="jaxws-war.html" target="_top">handler config</a>.</p><p>For example:</p><div class="informalexample"><pre class="programlisting"><span class="hl-directive" style="color: maroon">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="ReservedWord">&lt;endpoints</span> <span class="Identifier">xmlns</span>=<span class="String">'http://java.sun.com/xml/ns/jax-ws/ri/runtime'</span>
        <span class="Identifier">xmlns:javaee</span>=<span class="String">"http://java.sun.com/xml/ns/javaee"</span> <span class="Identifier">version</span>=<span class="String">'2.0'</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;endpoint</span> <span class="Identifier">name</span>=<span class="String">'AddNumbers'</span>
            <span class="Identifier">implementation</span>=<span class="String">'provider.server.AddNumbersImpl'</span>
            <span class="Identifier">wsdl</span>=<span class="String">'WEB-INF/wsdl/AddNumbers.wsdl'</span>
            <span class="Identifier">service</span>=<span class="String">'{http://duke.example.org}AddNumbersService'</span>
            <span class="Identifier">port</span>=<span class="String">'{http://duke.example.org}AddNumbersPort'</span>
            <span class="Identifier">url-pattern</span>=<span class="String">'/addnumbers'</span><span class="ReservedWord">/&gt;</span>
    <span class="ReservedWord">&lt;javaee:handler-chain&gt;</span>
        <span class="ReservedWord">&lt;javaee:handler-chain-name&gt;</span>my handler<span class="ReservedWord">&lt;/javaee:handler-chain-name&gt;</span>
        <span class="ReservedWord">&lt;javaee:handler&gt;</span>
            <span class="ReservedWord">&lt;javaee:handler-name&gt;</span>MyHandler<span class="ReservedWord">&lt;/javaee:handler-name&gt;</span>
            <span class="ReservedWord">&lt;javaee:handler-class&gt;</span>provider.server.MyHandler
            <span class="ReservedWord">&lt;/javaee:handler-class&gt;</span>
        <span class="ReservedWord">&lt;/javaee:handler&gt;</span>
    <span class="ReservedWord">&lt;/javaee:handler-chain&gt;</span>
<span class="ReservedWord">&lt;/endpoints&gt;</span></pre></div></div></div><div lang="en" class="section" title="3.&nbsp;AsyncProvider"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-asyncprovider">3.&nbsp;AsyncProvider</h2></div></div></div><p>Web Service endpoints may choose to work at the XML message level by
    implementing the <code class="literal">Provider</code> interface. The related
    information about <code class="literal">Provider</code> endpoints is documented in
    <a class="xref" href="ch03.html#users-guide-provider" title="2.&nbsp;Provider">Provider</a> page.
    However <code class="literal">Provider</code> endpoints are synchronous i.e. they
    receive XML requests and they return XML responses synchronously in
    <code class="literal">invoke()</code> method. If the endpoint wants to spawn a
    thread to process the request, it would block the jax-ws runtime thread
    and has to manage all the low details synchronizing the threads when the
    response is available. Also blocking a thread doesn't really scale well
    especially when the underlying transport is capable of handling
    asynchronous request and responses. RI provides an implemention specific
    solution to this problem by introducing <code class="literal">AsyncProvider.</code>
    This is similar to <code class="literal">Provider</code> endpoints but the
    difference is that the endpoint implementations have to implement
    <code class="literal">AsyncProvider</code> interface.</p><div class="section" title="3.1.&nbsp;AsyncProvider Example"><div class="titlepage"><div><div><h3 class="title" id="section-091974998856598">3.1.&nbsp;<code class="literal">AsyncProvider</code> Example</h3></div></div></div><p>The following example shows an <code class="literal">AsyncProvider</code>
        example that accesses the payload of the request.</p><div class="informalexample"><pre class="programlisting"><span class="Annotation">@WebServiceProvider</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AsyncProviderImpl <span class="ReservedWord">implements</span> AsyncProvider&lt;Source&gt; {
    
    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> invoke(Source source, AsyncProviderCallback cbak, 
                       WebServiceContext ctxt) {

        <span class="Comment">// ...</span>
        
    }
    
}</pre></div></div><div class="section" title="3.2.&nbsp;AsyncProvider sample"><div class="titlepage"><div><div><h3 class="title" id="section-930633228695613">3.2.&nbsp;<code class="literal">AsyncProvider</code> sample</h3></div></div></div><p>See a <a class="link" href="../samples/asyncprovider/Readme.txt" target="_top">sample</a> that
        illustrates <code class="literal">AsyncProvider</code> endpoints.</p></div><div class="section" title="3.3.&nbsp;AsyncService sample"><div class="titlepage"><div><div><h3 class="title" id="section-5233554712491355">3.3.&nbsp;<code class="literal">AsyncService</code> sample</h3></div></div></div><p>See another <a class="link" href="../samples/asyncservice/Readme.txt" target="_top">sample</a> that
        illustrates <code class="literal">AsyncProvider</code> endpoint that uses
        asynchronous servlet as the transport to bring true asynchronity on
        the server-side. See <a class="link" href="http://weblogs.java.net/blog/ramapulavarthi/archive/2010/08/18/new-asynchronous-servlet-transport-jax-ws-ri" target="_top">New
        Asynchronous Servlet Transport in JAX-WS RI</a> for mroe details on
        this feature.</p></div></div><div lang="en" class="section" title="4.&nbsp;Dispatch"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-dispatch">4.&nbsp;Dispatch</h2></div></div></div><p>Web service client applications may choose to work at the XML
    message level by using the <code class="literal">Dispatch&lt;T&gt;</code> APIs. The
    <code class="literal">javax.xml.ws.Dispatch&lt;T&gt;</code> interface provides
    support for the dynamic invocation of service endpoint operations.</p><p>Four Message Exchange Protocols(MEP) are supported:
    request-response, one way, asynchronous polling, and callback. Each of
    these invocation MEPs are required with JAXB data bound
    <code class="literal">java.lang.Object</code>,
    <code class="literal">javax.xml.transform.Source</code>,
    <code class="literal">javax.xml.soap.SOAPMessage</code> and
    <code class="literal">javax.activation.DataSource</code> object requests.</p><p>The <code class="literal">javax.xml.ws.Service</code> acts as a factory for
    the creation of <code class="literal">Dispatch&lt;T&gt;</code> instances. In
    addition, a <code class="literal">Dispatch&lt;T&gt;</code> instance is created in
    either <code class="literal">Service.Mode.PAYLOAD</code> or
    <code class="literal">Service.Mode.MESSAGE</code> modes. A
    <code class="literal">javax.xml.soap.SOAPMessage</code> request can only be used
    with a <code class="literal">Dispatch&lt;T&gt;</code> instance of
    <code class="literal">Service.Mode.MESSAGE</code> and using the SOAP Binding. A
    <code class="literal">javax.activation.DataSource</code> request can only be used
    with a <code class="literal">Dispatch&lt;T&gt;</code> instance of
    <code class="literal">Service.Mode.MESSAGE</code> and using the XML/HTTP
    Binding.</p><p>Note that the <code class="literal">Dispatch&lt;T&gt;</code> instance simply
    acts as a conduit for the request. No validation of the message is
    required to be performed by the implementation, though some may catch
    errors during request processing. It is up to the client program to supply
    well-formed XML requests.</p><div class="section" title="4.1.&nbsp;Programming Model"><div class="titlepage"><div><div><h3 class="title" id="section-71379735580733">4.1.&nbsp;Programming Model</h3></div></div></div><div class="section" title="4.1.1.&nbsp;Create a dynamic Service."><div class="titlepage"><div><div><h4 class="title" id="section-441203977673228">4.1.1.&nbsp;Create a dynamic <code class="literal">Service</code>.</h4></div></div></div><p>The <code class="literal">javax.xml.ws.Service</code> acts as a
            factory for the creation of a dynamic <code class="literal">Service</code>.
            When created for use with <code class="literal">Dispatch&lt;T&gt;</code>
            APIs the <code class="literal">Service</code> created can be either a
            <code class="literal">Service</code> that has knowledge of the binding
            information of a known <code class="literal">Service</code> or no knowledge
            of any specific <code class="literal">Service</code>.</p><p>That is, when the <code class="literal">Service</code> is created with
            a WSDL file the port(s) binding ID, QName, and endpoint address
            are known to the <code class="literal">Service</code>.</p><p>The methods to create a dynamic <code class="literal">Service</code>
            are shown here:</p><div class="informalexample"><pre class="programlisting">Service service = Service.create(QName serviceQName);
Service service = Service.create(URL wsdlLocation, QName serviceQName);</pre></div><p>A <code class="literal">Dispatch&lt;T&gt;</code> instance must be
            bound to a specific port and endpoint before use. The service has
            an <code class="literal">addPort(QName portName, URI bindingID, String
            endpointAddress)</code> method that the client program can
            invoke for <code class="literal">Dispatch&lt;T&gt;</code> objects. Ports
            created using this method can only be used with
            <code class="literal">Dispatch&lt;T&gt;</code> instances.</p><p>If the <code class="literal">Service</code> has been created with WSDL
            binding information the the port need not be added as the
            <code class="literal">Dispatch&lt;T&gt;</code> instance will be created
            specific for the binding information provided in the supplied WSDL
            file.</p><p>Developers who have used web service applications in the
            past are familiar with the port <code class="literal">QName</code> and
            endpoint address parameters of this method. JAX-WS RI 2.2.7
            supports three <code class="literal">Binding</code> URI's, that of the SOAP
            1.1, the SOAP 1.2 and XML/HTTP Binding. For more information on
            SOAP 1.2 support please refer to the SOAP 1.2 documents. For the
            XML/HTTP binding please see chapter 11 of the JAX-WS 2.0 PFD
            Specification.</p><p>The addition of the SOAP 1.1 port using the
            <code class="literal">Service</code> API is shown here:</p><div class="informalexample"><pre class="programlisting">service.addPort(QName portName, String SOAPBinding.SOAP11HTTP_BINDING,
        String endpointAddress);</pre></div><p>SOAP 1.2 support has been implemented for
            <code class="literal">Dispatch</code>. This requires only one change in the
            programming model. The addition of the SOAP 1.2 port using the
            <code class="literal">Service</code> API is shown here:</p><div class="informalexample"><pre class="programlisting">service.addPort(QName portName, String SOAPBinding.SOAP12HTTP_BINDING,
        String endpointAddress);</pre></div><p>XML/HTTP binding support has been implemented for
            <code class="literal">Dispatch</code>. The creation of the XML/HTTP port
            using the <code class="literal">Service</code> API is shown here:</p><div class="informalexample"><pre class="programlisting">service.addPort(QName portName, String HTTPBinding.HTTP_BINDING,
        String endpointAddress);</pre></div></div><div class="section" title="4.1.2.&nbsp;Create a Dispatch<T&gt; instance."><div class="titlepage"><div><div><h4 class="title" id="section-7295163740787236">4.1.2.&nbsp;Create a <code class="literal">Dispatch&lt;T&gt;</code>
            instance.</h4></div></div></div><p>The <code class="literal">Dispatch&lt;T&gt;</code> object can be
            created using either of these two <code class="literal">Service</code>
            methods:</p><div class="informalexample"><pre class="programlisting">Dispatch dispatch = service.createDispatch(QName portName, 
        Class clazz, Service.Mode mode);
Dispatch dispatch = service.createDispatch(QName portName, 
        JAXBContext jaxbcontext, Service.Mode mode);</pre></div><p>For a <code class="literal">javax.xml.transform.Source</code> and JAXB
            data binding <code class="literal">java.lang.Object</code>
            <code class="literal">Dispatch&lt;T&gt;</code> can be created in both
            <code class="literal">Service.Mode.PAYLOAD</code> and
            <code class="literal">Service.Mode.MESSAGE</code> modes. A
            <code class="literal">javax.xml.soap.SOAPMessage</code> can only be created
            in <code class="literal">Service.Mode.MESSAGE</code> mode. The first form of
            the <code class="literal">createDispatch</code> method is used to create a
            <code class="literal">javax.xml.transform.Source</code> or
            <code class="literal">javax.xml.soap.SOAPMessage</code> specific to the
            <code class="literal">Dispatch&lt;T&gt;</code> instance.</p><p>A JAXB object-specific instance can only be created using
            the second method listed above.</p><p>It is important to note that once the
            <code class="literal">Dispatch&lt;T&gt;</code> instance is created it is
            static. That is, its <code class="literal">Service.Mode</code> or request
            type can not be changed. The instance can be reused given the
            caveat that if it is a JAXB-specific
            <code class="literal">Dispatch&lt;T&gt;</code> it must be reused with
            objects known to the same <code class="literal">JAXBContext</code>.</p></div><div class="section" title="4.1.3.&nbsp;Set the context Map<String, Object&gt; for the request."><div class="titlepage"><div><div><h4 class="title" id="section-568116144017489">4.1.3.&nbsp;Set the context <code class="literal">Map&lt;String,
            Object&gt;</code> for the request.</h4></div></div></div><p>The <code class="literal">Dispatch&lt;T&gt;</code> interface extends
            the <code class="literal">javax.xml.ws.BindingProvider</code> interface. The
            <code class="literal">BindingProvider</code> interface defines accessor
            methods for the request and response context maps. Standard
            <code class="literal">BindingProvider</code> properties are defined by the
            JAX-WS 2.0 specification and the client program may set and get
            these properties. The application may also define
            application-specific properties, but the specification discourages
            this for portability reasons.</p></div><div class="section" title="4.1.4.&nbsp;Prepare the message request."><div class="titlepage"><div><div><h4 class="title" id="section-14558813271967286">4.1.4.&nbsp;Prepare the message request.</h4></div></div></div><p>This is the client developer's responsibility. For examples
            of how to prepare specific request types refer to the
            <code class="literal">Dispatch&lt;T&gt;</code> sample applications.</p></div><div class="section" title="4.1.5.&nbsp;Invoke the web service request."><div class="titlepage"><div><div><h4 class="title" id="section-628591767064064">4.1.5.&nbsp;Invoke the web service request.</h4></div></div></div><p>Four types of invocation MEPs are supported using the
            methods below. In methods that produce a response, the type of
            <code class="literal">Object</code> returned will be of the same type as the
            request. For example, a <code class="literal">SOAPMessage</code> request
            will return a <code class="literal">SOAPMessage</code> response.</p><div class="informalexample"><pre class="programlisting">Object response = dispatch.invoke(T);
dispatch.invokeOneway(T);
Response&lt;T&gt; response = dispatch.invokeAsync(T);
Future&lt;?&gt; response = dispatch.invokeAsync(T, AsyncHandler);</pre></div></div></div><div class="section" title="4.2.&nbsp;Dispatch and Asynchronous Invocations"><div class="titlepage"><div><div><h3 class="title" id="section-21282255346754875">4.2.&nbsp;Dispatch and Asynchronous Invocations</h3></div></div></div><p>Asynchronous invocations require special consideration. The
        first form of the <code class="literal">invokeAsync</code> method is a polling
        method. The response, <code class="literal">Response&lt;T&gt;</code>,returns to
        the user immediately and may be polled for completion. In the
        meantime, the client program can do other work.</p><p>The <code class="literal">javax.xml.ws.Response&lt;T&gt;</code> implements
        the <code class="literal">java.util.concurrent.Future&lt;T&gt;</code> interface
        that is included in J2SE 5.0. The <code class="literal">Response&lt;T&gt;</code>
        object returns the actual response via its <code class="literal">get</code>
        method, which blocks if the response is not ready to be
        returned.</p><p>The <code class="literal">Future&lt;T&gt;</code> interface also has a
        <code class="literal">cancel</code> method that will attempt to cancel the
        request invocation if the request is being invoked.</p><p>Faults returned from the service or exceptions thrown during the
        invocation are returned when the <code class="literal">Response&lt;T&gt;</code>
        <code class="literal">get</code> method is called. Because the execution doesn't
        occur in the main thread, the exception or fault returned is wrapped
        in an <code class="literal">java.util.concurrent.ExecutionException</code>. To
        obtain the actual cause use the <code class="literal">getCause</code> method of
        <code class="literal">ExecutionException</code>.</p><p>For more information on the
        <code class="literal">java.util.concurrent.Future&lt;?&gt;</code> interface see
        the J2SE 5.0 documentation.</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">public</span> <span class="ReservedWord">interface</span> Response&lt;T&gt; <span class="ReservedWord">extends</span> java.util.concurrent.Future&lt;T&gt; {

    Map&lt;String, Object&gt; getContext();
    
}</pre></div><p>The second form of the <code class="literal">invokeAsync</code> method has
        a second parameter of type
        <code class="literal">javax.xml.ws.AsyncHandler</code>. The purpose of the
        <code class="literal">AsyncHandler</code> is to get and handle the the response
        or any fault thrown in an application-specific way. The
        <code class="literal">AsyncHandler</code> has a method
        <code class="literal">handleResponse(Response&lt;T&gt;)</code> that takes a
        <code class="literal">javax.xml.ws.Response&lt;T&gt;</code> parameter. This
        method gets the response or any faults and processes them according to
        behavior defined in the application. Note that it is the
        responsibility of the client program to implement the asynchronous
        handler.</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">class</span> ResponseHandler <span class="ReservedWord">implements</span> javax.xml.ws.AsyncHandler {
    
    <span class="ReservedWord">public</span> handleResponse(Response&lt;T&gt;);
    
}</pre></div><p>This form of the asynchronous invocation method returns a
        <code class="literal">Future&lt;?&gt;</code> object with wildcard type. As in
        the asynchronous poll invocation, the
        <code class="literal">Future&lt;T&gt;</code> object can be polled to see if the
        response is ready. However, calling the <code class="literal">get</code> method
        will not return the response of the invocation, but an object of
        indeterminate type.</p><p>Examples of synchronous and asynchronous invocations are shown
        in the <code class="literal">Dispatch&lt;T&gt;</code> samples. For convenience
        an example of <code class="literal">Response&lt;T&gt;</code> usage is display
        here:</p><div class="informalexample"><pre class="programlisting">Response&lt;Source&gt; response = dispatch.invokeAsync(Source);
<span class="ReservedWord">while</span> (!response.isDone()) {
    <span class="Comment">//go off and do some work</span>
}

<span class="ReservedWord">try</span> {
    <span class="Comment">//get the actual result</span>
    Source result = (javax.xml.transform.Source) response.get();
    <span class="Comment">//do something with the result</span>
} <span class="ReservedWord">catch</span> (ExecutionException ex) {
    <span class="Comment">//get the actual cause</span>
    Throwable cause = ex.getCause();
} <span class="ReservedWord">catch</span> (InterupptedException ie) {
    <span class="Comment">//note interruptions</span>
    System.out.println(<span class="String">"Operation invocation interrupted"</span>);
}</pre></div></div></div><div lang="en" class="section" title="5.&nbsp;Asynchronous Client"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-asynchronous-client">5.&nbsp;Asynchronous Client</h2></div></div></div><p>This document describes how a client application can invoke a remote
    web service asynchronously. It can do so either by generating a static
    stub or using the Dispatch API.</p><div class="section" title="5.1.&nbsp;Asynchronous Invocation Using Static Stub"><div class="titlepage"><div><div><h3 class="title" id="section-346120708971664">5.1.&nbsp;Asynchronous Invocation Using Static Stub</h3></div></div></div><p>Client application should apply
        <code class="literal">jaxws:enableAsyncMapping</code> binding declaration to the
        WSDL file to generate asynchronous method in the service endpoint
        interface. Please refer to <a class="xref" href="ch03.html#asynchrony" title="9.2.4.&nbsp;Asynchrony">Asynchrony</a> for details on how this can be applied to
        the WSDL file.</p><p>Lets look at the following WSDL excerpt:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;definitions</span>
        <span class="Identifier">name</span>=<span class="String">"AddNumbers"</span>
        <span class="Identifier">targetNamespace</span>=<span class="String">"http://duke.example.org"</span>
        <span class="Identifier">xmlns:tns</span>=<span class="String">"http://duke.example.org"</span>
        <span class="Identifier">xmlns</span>=<span class="String">"http://schemas.xmlsoap.org/wsdl/"</span>
        <span class="Identifier">xmlns:xsd</span>=<span class="String">"http://www.w3.org/2001/XMLSchema"</span>
        <span class="Identifier">xmlns:soap</span>=<span class="String">"http://schemas.xmlsoap.org/wsdl/soap/"</span><span class="ReservedWord">&gt;</span>
    
    ...
    
    <span class="ReservedWord">&lt;portType</span> <span class="Identifier">name</span>=<span class="String">"AddNumbersImpl"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;operation</span> <span class="Identifier">name</span>=<span class="String">"addNumbers"</span><span class="ReservedWord">&gt;</span>
            <span class="ReservedWord">&lt;input</span> <span class="Identifier">message</span>=<span class="String">"tns:addNumbers"</span><span class="ReservedWord">/&gt;</span>
            <span class="ReservedWord">&lt;output</span> <span class="Identifier">message</span>=<span class="String">"tns:addNumbersResponse"</span><span class="ReservedWord">/&gt;</span>
        <span class="ReservedWord">&lt;/operation&gt;</span>
    <span class="ReservedWord">&lt;/portType&gt;</span>
    <span class="ReservedWord">&lt;binding</span> <span class="Identifier">name</span>=<span class="String">"AddNumbersImplBinding"</span> <span class="Identifier">type</span>=<span class="String">"tns:AddNumbersImpl"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;soap:binding</span> <span class="Identifier">transport</span>=<span class="String">"http://schemas.xmlsoap.org/soap/http"</span>
                <span class="Identifier">style</span>=<span class="String">"document"</span><span class="ReservedWord">/&gt;</span>
        <span class="ReservedWord">&lt;operation</span> <span class="Identifier">name</span>=<span class="String">"addNumbers"</span><span class="ReservedWord">&gt;</span>
            <span class="ReservedWord">&lt;soap:operation</span> <span class="Identifier">soapAction</span>=<span class="String">""</span><span class="ReservedWord">/&gt;</span>
            <span class="ReservedWord">&lt;input&gt;</span>
                <span class="ReservedWord">&lt;soap:body</span> <span class="Identifier">use</span>=<span class="String">"literal"</span><span class="ReservedWord">/&gt;</span>
            <span class="ReservedWord">&lt;/input&gt;</span>
            <span class="ReservedWord">&lt;output&gt;</span>
                <span class="ReservedWord">&lt;soap:body</span> <span class="Identifier">use</span>=<span class="String">"literal"</span><span class="ReservedWord">/&gt;</span>
            <span class="ReservedWord">&lt;/output&gt;</span>
        <span class="ReservedWord">&lt;/operation&gt;</span>
    <span class="ReservedWord">&lt;/binding&gt;</span>
    
    ...
    
<span class="ReservedWord">&lt;/definitions&gt;</span></pre></div><p>In order to generate a service endpoint interface with
        asynchronous methods the following binding declaration file will be
        passed to <span class="command"><strong>wsimport</strong></span>:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;bindings</span> 
        <span class="Identifier">xmlns:xsd</span>=<span class="String">"http://www.w3.org/2001/XMLSchema"</span>
        <span class="Identifier">xmlns:wsdl</span>=<span class="String">"http://schemas.xmlsoap.org/wsdl/"</span>
        <span class="Identifier">wsdlLocaption</span>=<span class="String">"http://localhost:8080/jaxws-async/addnumbers?WSDL"</span>
        <span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/jaxws"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;bindings</span> <span class="Identifier">node</span>=<span class="String">"wsdl:definitions"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;package</span> <span class="Identifier">name</span>=<span class="String">"async.client"</span><span class="ReservedWord">/&gt;</span>
        <span class="ReservedWord">&lt;enableAsyncMapping&gt;</span>true<span class="ReservedWord">&lt;/enableAsyncMapping&gt;</span>
    <span class="ReservedWord">&lt;/bindings&gt;</span>
<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div><p>It produces the following service endpoint interface
        (annotations are removed from the synchronous method for better
        readability):</p><div class="informalexample"><pre class="programlisting">//synchronous method
public int addNumbers(int number1, int number2) throws java.rmi.RemoteException;

//async polling Method
public Response&lt;AddNumbersResponse&gt; addNumbers(int number1, int number2);

//async callback Method
public Future&lt;?&gt; addNumbers(int number1, int number2, AsyncHandler&lt;AddNumbersResponse&gt;);</pre></div><div class="section" title="5.1.1.&nbsp;Async Polling"><div class="titlepage"><div><div><h4 class="title" id="section-449139041763976">5.1.1.&nbsp;Async Polling</h4></div></div></div><div class="informalexample"><pre class="programlisting">//async polling Method
public Response&lt;AddNumbersResponse&gt; addNumbers(int number1, int number2);</pre></div><p>Typically a client application will invoke the async polling
            operation on the stub and check for a response on the returned
            <code class="literal">Response</code> object. The response is available when
            <code class="literal">Response.isDone</code> returns true.</p><div class="informalexample"><pre class="programlisting">javax.xml.ws.Response&lt;AddNumbersResponse&gt; resp = port
        .addNumbersAsync(<span class="Numeric">10</span>, <span class="Numeric">20</span>);
<span class="ReservedWord">while</span> (!resp.isDone()) {
    <span class="Comment">//do something</span>
}
System.out.println(<span class="String">"The sum is: "</span> + resp.get().getReturn());

...</pre></div></div><div class="section" title="5.1.2.&nbsp;Async Callback"><div class="titlepage"><div><div><h4 class="title" id="section-73214284296898">5.1.2.&nbsp;Async Callback</h4></div></div></div><div class="informalexample"><pre class="programlisting">//async callback Method
public Future&lt;?&gt; addNumbers(int number1, int number2, AsyncHandler&lt;AddNumbersResponse&gt;);</pre></div><p>Here the client application provides an
            <code class="literal">AsyncHandler</code> by implementing the
            <code class="literal">javax.xml.ws.AsyncHandler&lt;T&gt;</code>
            interface.</p><div class="informalexample"><pre class="programlisting"><span class="Comment">/**
 * Async callback handler
 */</span>
<span class="ReservedWord">class</span> AddNumbersCallbackHandler <span class="ReservedWord">implements</span> 
        AsyncHandler&lt;AddNumbersResponse&gt; {
    <span class="ReservedWord">private</span> AddNumbersResponse output;

    <span class="Comment">/**
     * @see javax.xml.ws.AsyncHandler#handleResponse(javax.xml.ws.Response)
     */</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> handleResponse(Response&lt;AddNumbersResponse&gt; response) {
        <span class="ReservedWord">try</span> {
            output = response.get();
        } <span class="ReservedWord">catch</span> (ExecutionException e) {
            e.printStackTrace();
        } <span class="ReservedWord">catch</span> (InterruptedException e) {
            e.printStackTrace();
        }
    }

    AddNumbersResponse getResponse() {
        <span class="ReservedWord">return</span> output;
    }
}</pre></div><p>The async handler is then passed as the last parameter of
            the async callback method:</p><div class="informalexample"><pre class="programlisting"><span class="Comment">//instantiates the callback handler</span>
AddNumbersCallbackHandler callbackHandler = <span class="ReservedWord">new</span> 
        AddNumbersCallbackHandler();

<span class="Comment">//invoke the async callback method</span>
Future&lt;?&gt; resp = port.addNumbersAsync(number1, number2, callbackHandler);
<span class="ReservedWord">while</span> (!resp.isDone()) {
    <span class="Comment">//do something</span>
}
System.out.println(<span class="String">"The sum is: "</span> + callbackHandler.getResponse().getReturn());</pre></div></div></div><div class="section" title="5.2.&nbsp;Asynchronous Invocation Using Dispatch"><div class="titlepage"><div><div><h3 class="title" id="section-85273158180115">5.2.&nbsp;Asynchronous Invocation Using Dispatch</h3></div></div></div><p>For information on the Dispatch API and asynchronous invocations
        see <a class="xref" href="ch03.html#users-guide-dispatch" title="4.&nbsp;Dispatch">Dispatch</a></p></div></div><div lang="en" class="section" title="6.&nbsp;Handler"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-handler">6.&nbsp;Handler</h2></div></div></div><div class="section" title="6.1.&nbsp;Handler Types"><div class="titlepage"><div><div><h3 class="title" id="section-524340464580105">6.1.&nbsp;Handler Types</h3></div></div></div><p>JAX-WS 2.0 defines a <code class="literal">Handler</code> interface, with
        subinterfaces <code class="literal">LogicalHandler</code> and
        <code class="literal">SOAPHandler</code>. The <code class="literal">Handler</code>
        interface contains <code class="literal">handleMessage(C context)</code> and
        <code class="literal">handleFault(C context)</code> methods, where
        <code class="literal">C</code> extends <code class="literal">MessageContext</code>. A
        property in the <code class="literal">MessageContext</code> object is used to
        determine if the message is inbound or outbound.
        <code class="literal">SOAPHandler</code> objects have access to the full soap
        message including headers. Logical handlers are independent of
        protocol and have access to the payload of the message.</p><p>The new handler types can now be written without casting the
        message context object that is passed to them. For instance:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">public</span> <span class="ReservedWord">class</span> MyLogicalHandler <span class="ReservedWord">implements</span> 
        LogicalHandler&lt;LogicalMessageContext&gt; {

    <span class="ReservedWord">public</span> <span class="ReservedWord">boolean</span> handleMessage(LogicalMessageContext messageContext) {
        LogicalMessage msg = messageContext.getMessage();
        <span class="ReservedWord">return</span> true;
    }
    <span class="Comment">// other methods</span>
}</pre></div><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">public</span> <span class="ReservedWord">class</span> MySOAPHandler <span class="ReservedWord">implements</span> SOAPHandler&lt;SOAPMessageContext&gt; {

    <span class="ReservedWord">public</span> <span class="ReservedWord">boolean</span> handleMessage(SOAPMessageContext messageContext) {
        SOAPMessage msg = messageContext.getMessage();
        <span class="ReservedWord">return</span> true;
    }
    <span class="Comment">// other methods</span>
}</pre></div><p>A <code class="literal">close(C context)</code> method has been added that
        is called on the handlers at the conclusion of a message exchange
        pattern. This allows handlers to clean up any resources that were used
        for the processing of a request-only or request/response
        exchange.</p><p>The <code class="literal">init()</code> and <code class="literal">destroy()</code>
        methods of the handler lifecycle no longer exist. Instead, a method
        may be annotated with the <code class="literal">@PostConstruct</code> annotation
        to be called after the handler is created or the
        <code class="literal">@PreDestroy</code> annotation to be called before the
        handler is destroyed. Note that the annotated methods must return
        <code class="literal">void</code> and take no arguments:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">import</span> javax.annotation.PostConstruct;
<span class="ReservedWord">import</span> javax.annotation.PreDestroy;

<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> MyLogicalHandler <span class="ReservedWord">implements</span> 
        LogicalHandler&lt;LogicalMessageContext&gt; {
    
    <span class="Annotation">@PostConstruct</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> methodA() {
    }

    <span class="Annotation">@PreDestroy</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> methodB() {
    }

    <span class="Comment">// other methods</span>
}</pre></div></div><div class="section" title="6.2.&nbsp;MessageContext"><div class="titlepage"><div><div><h3 class="title" id="section-276528078695232">6.2.&nbsp;MessageContext</h3></div></div></div><p>In the examples above, the <code class="literal">LogicalMessage</code>
        object allows a handler to get and set the message payload either as a
        JAXB object or as a <code class="literal">javax.xml.transform.Source</code>. The
        <code class="literal">SOAPMessage</code> object allows access to headers and the
        SOAP body of the message.</p><p>Both context objects extend <code class="literal">MessageContext</code>,
        which holds properties that the handlers can use to communicate with
        each other. A standard property
        <code class="literal">MessageContext.MESSAGE_OUTBOUND_PROPERTY</code> holds a
        <code class="literal">Boolean</code> that is used to determine the direction of
        a message. For example, during a request, the property would be
        <code class="literal">Boolean.TRUE</code> when seen by a client handler and
        <code class="literal">Boolean.FALSE</code> when seen by a server handler.</p><p>The message context object can also hold properties set by the
        client or provider. For instance, port proxy and dispatch objects both
        extend <code class="literal">BindingProvider</code>. A message context object
        can be obtained from both to represent the request or response
        context. Properties set in the request context can be read by the
        handlers, and the handlers may set properties on the message context
        objects passed to them. If these properties are set with the scope
        <code class="literal">MessageContext.Scope.APPLICATION</code> then they will be
        available in the response context to the client. On the server end, a
        context object is passed into the <code class="literal">invoke</code> method of
        a <code class="literal">Provider</code>.</p></div><div class="section" title="6.3.&nbsp;Handler Chain Configuration"><div class="titlepage"><div><div><h3 class="title" id="section-165423693536683">6.3.&nbsp;Handler Chain Configuration</h3></div></div></div><div class="section" title="6.3.1.&nbsp;Handler Files"><div class="titlepage"><div><div><h4 class="title" id="section-404105458093083">6.3.1.&nbsp;Handler Files</h4></div></div></div><p>Starting from a WSDL file, handler chain configuration is
            through WSDL customizations as defined by <a class="link" href="http://jcp.org/en/jsr/detail?id=109" target="_top">JSR 109</a>. A
            <code class="literal">&lt;handler-chains&gt;</code> element is added to the
            customization file. The following is a simple handler chain with
            one handler (customization may be on server or client
            side):</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;--</span> <span class="Identifier">excerpt</span> <span class="Identifier">from</span> <span class="Identifier">customization</span> <span class="Identifier">file</span> <span class="Identifier">--&gt;</span>
<span class="Identifier">&lt;bindings</span> <span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/jaxws"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;handler-chains</span> <span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/javaee"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;handler-chain&gt;</span>
            <span class="ReservedWord">&lt;handler&gt;</span>
                <span class="ReservedWord">&lt;handler-class&gt;</span>fromwsdl.handler_simple.common.TestHandler
                <span class="ReservedWord">&lt;/handler-class&gt;</span>
            <span class="ReservedWord">&lt;/handler&gt;</span>
        <span class="ReservedWord">&lt;/handler-chain&gt;</span>
    <span class="ReservedWord">&lt;/handler-chains&gt;</span>
<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div><p>Multiple <code class="literal">handler-chain</code> elements may exist
            within the <code class="literal">handler-chains</code> element. These may
            optionally use a service name, port name, or protocol pattern in
            their description to apply some chains to certain ports and
            protocols and not to others. For instance (note the wildcard
            character used in the service name):</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;--</span> <span class="Identifier">excerpt</span> <span class="Identifier">--&gt;</span>
<span class="Identifier">&lt;handler-chains</span> <span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/javaee"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;handler-chain&gt;</span>
        <span class="ReservedWord">&lt;service-name-pattern</span> <span class="Identifier">xmlns:ns1</span>=<span class="String">"urn:namespace"</span><span class="ReservedWord">&gt;</span>ns1:My*Service
        <span class="ReservedWord">&lt;/service-name-pattern&gt;</span>
        <span class="ReservedWord">&lt;handler&gt;</span>...<span class="ReservedWord">&lt;/handler&gt;</span>
    <span class="ReservedWord">&lt;/handler-chain&gt;</span>

    <span class="ReservedWord">&lt;handler-chain&gt;</span>
        <span class="ReservedWord">&lt;port-name-pattern</span> <span class="Identifier">xmlns:ns1</span>=<span class="String">"urn:namespace"</span><span class="ReservedWord">&gt;</span>ns1:HelloPort
        <span class="ReservedWord">&lt;/port-name-pattern&gt;</span>
        <span class="ReservedWord">&lt;handler&gt;</span>...<span class="ReservedWord">&lt;/handler&gt;</span>
    <span class="ReservedWord">&lt;/handler-chain&gt;</span>

    <span class="ReservedWord">&lt;handler-chain&gt;</span>
        <span class="ReservedWord">&lt;protocol-bindings&gt;</span>##SOAP11_HTTP<span class="ReservedWord">&lt;/protocol-bindings&gt;</span>
        <span class="ReservedWord">&lt;handler&gt;</span>...<span class="ReservedWord">&lt;/handler&gt;</span>
    <span class="ReservedWord">&lt;/handler-chain&gt;</span>
<span class="ReservedWord">&lt;/handler-chains&gt;</span></pre></div><p>Handlers will appear in the final handler chain in the order
            that they are included in the customization file. However, logical
            handlers will be sorted out and called before protocol handlers
            during execution.</p><p>Starting from a Java class, annotations are used to describe
            the handler chain as defined by <a class="link" href="http://jcp.org/en/jsr/detail?id=181" target="_top">JSR 181</a>.
            The following example uses the <code class="literal">@HandlerChain</code>
            annotation to refer to a file describing the chain.</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">import</span> javax.jws.HandlerChain;
<span class="ReservedWord">import</span> javax.jws.WebService;

<span class="Annotation">@WebService</span>
<span class="Annotation">@HandlerChain(file = "handlers.xml")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> MyServiceImpl {
    <span class="Comment">// implementation of class</span>
}</pre></div><p>An example <code class="literal">handlers.xml</code> file is shown
            below. The schema is the same that is used for the
            customization.</p><div class="informalexample"><pre class="programlisting"><span class="hl-directive" style="color: maroon">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="ReservedWord">&lt;jws:handler-chains</span> <span class="Identifier">xmlns:jws</span>=<span class="String">"http://java.sun.com/xml/ns/javaee"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;jws:handler-chain&gt;</span>
        <span class="ReservedWord">&lt;jws:handler&gt;</span>
            <span class="ReservedWord">&lt;jws:handler-class&gt;</span>fromjava.handler_simple.common.TestHandler
            <span class="ReservedWord">&lt;/jws:handler-class&gt;</span>
        <span class="ReservedWord">&lt;/jws:handler&gt;</span>
    <span class="ReservedWord">&lt;/jws:handler-chain&gt;</span>
<span class="ReservedWord">&lt;/jws:handler-chains&gt;</span></pre></div><p>When packaging the service, the
            <code class="filename">handlers.xml</code> file must be in the classpath
            within the WAR file, either directly under
            <code class="literal">WEB-INF/classes</code> or further down in the same
            package as the service class file.</p><p>On the server side, the handlers may be configured in the
            <code class="filename">sun-jaxws.xml</code>deployment descriptor as well. A
            handler chain specified here will override handlers in WSDL
            customizations or annotated classes. The schema for the handler
            section is the same as in the previous examples:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;endpoints</span> <span class="Identifier">...&gt;</span>
    <span class="Identifier">&lt;endpoint...&gt;</span>
        <span class="Identifier">&lt;handler-chains</span> <span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/javaee"</span><span class="ReservedWord">&gt;</span>
            <span class="ReservedWord">&lt;handler-chain&gt;</span>
                ...
            <span class="ReservedWord">&lt;/handler-chain&gt;</span>
        <span class="ReservedWord">&lt;/handler-chains&gt;</span>
    <span class="ReservedWord">&lt;/endpoint&gt;</span>
<span class="ReservedWord">&lt;/endpoints&gt;</span></pre></div></div><div class="section" title="6.3.2.&nbsp;Programmatic Case"><div class="titlepage"><div><div><h4 class="title" id="section-34700025143465">6.3.2.&nbsp;Programmatic Case</h4></div></div></div><p>Handler chains may be configured on the client side at
            runtime by setting a chain directly on a
            <code class="literal">BindingProvider</code> (e.g., a
            <code class="literal">Dispatch</code> object or a port proxy) or by using a
            <code class="literal">HandlerResolver</code>. This example shows how to add
            a handler chain to a port proxy:</p><div class="informalexample"><pre class="programlisting"><span class="Comment">// given proxy interface HelloPortType</span>
HelloPortType myProxy = <span class="Comment">// create proxy</span>

Binding binding = ((BindingProvider) myProxy).getBinding();

<span class="Comment">// can create new list or use existing one</span>
List&lt;Handler&gt; handlerList = binding.getHandlerChain();

handlerList.add(<span class="ReservedWord">new</span> MyHandler());
binding.setHandlerChain(handlerList);</pre></div><p>To configure the handlers that are added to newly created
            <code class="literal">Binding</code> objects, add a handler resolver to the
            service with <code class="literal">setHandlerResolver()</code>. The new
            resolver will be used whenever a
            <code class="literal">BindingProvider</code> is created from the service. An
            example resolver is as follows:</p><div class="informalexample"><pre class="programlisting"><span class="Comment">/*
 * Add handlers to the returned list based on the information
 * in info.getBindingID(), getPortName(), and/or getServiceName().
 */</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> MyResolver <span class="ReservedWord">implements</span> HandlerResolver {
    
    <span class="ReservedWord">public</span> List&lt;Handler&gt; getHandlerChain(PortInfo info) {
        List&lt;Handler&gt; handlers = <span class="ReservedWord">new</span> ArrayList&lt;Handler&gt;();
        <span class="Comment">// add handlers to list based on PortInfo information</span>
        <span class="ReservedWord">return</span> handlers;
    }
    
}</pre></div><p>A resolver that modifies the initially configured handler
            chains could be written by calling
            <code class="literal">service.getHandlerResolver()</code> and passing the
            original resolver to a new one:</p><div class="informalexample"><pre class="programlisting"><span class="Comment">// original HandlerResolver passed in constructor or setter method</span>
<span class="ReservedWord">public</span> List&lt;Handler&gt; getHandlerChain(PortInfo info) {
    List&lt;Handler&gt; handlers = originalResolver.getHandlerChain(info);
    <span class="Comment">// alter list based on PortInfo information</span>
    <span class="ReservedWord">return</span> handlers;
}</pre></div></div></div><div class="section" title="6.4.&nbsp;Handler Samples"><div class="titlepage"><div><div><h3 class="title" id="section-8594509924044">6.4.&nbsp;Handler Samples</h3></div></div></div><p>The <span class="application">fromjavahandler</span> and
        <span class="application">fromwsdlhandler</span> samples set a
        <code class="literal">SOAPHandler</code> on the client and server. This handler
        simply outputs the contents of the SOAP message and can be used to see
        the requests and responses being passed back and forth. See the sample
        documentation for information on running the samples.</p></div></div><div lang="en" class="section" title="7.&nbsp;MTOM and Swaref"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-mtom-and-swaref">7.&nbsp;MTOM and Swaref</h2></div></div></div><div class="section" title="7.1.&nbsp;MTOM and XOP"><div class="titlepage"><div><div><h3 class="title" id="mtom-and-xop">7.1.&nbsp;MTOM and XOP</h3></div></div></div><p><a class="link" href="http://www.w3.org/TR/soap12-mtom/" target="_top">MTOM</a>
        (Message Transmission and Optimization Mechanism) together with <a class="link" href="http://www.w3.org/TR/xop10/" target="_top">XOP</a> (XML Binary
        Optimized Packaging) defines how an XML binary data such as
        <code class="literal">xs:base64Binary</code> or <code class="literal">xs:hexBinary</code>
        can be optimally transmitted over the wire. XML type, such as
        <code class="literal">xs:base64Binary</code> is sent in lined inside the SOAP
        envelope. This gets quite in-efficient when the data size is more, for
        example a SOAP endpoint that exchanges images/songs etc. MTOM
        specifies how XOP packaging can be used to send the binary data
        optimally.</p></div><div class="section" title="7.2.&nbsp;MTOM in JAX-WS 2.0"><div class="titlepage"><div><div><h3 class="title" id="mtom-in-jaxws-2-0">7.2.&nbsp;MTOM in JAX-WS 2.0</h3></div></div></div><p>MTOM feature is disabled in JAX-WS by default. It can be enabled
        on the client and server. Once enabled all the XML binary data, XML
        elements of type <code class="literal">xs:base64Binary</code> and
        <code class="literal">xs:hexBinary</code> is optimally transmitted. Currently
        MTOM works only with proxy port.</p><div class="section" title="7.2.1.&nbsp;xmime:expectedContentType to Java type mapping"><div class="titlepage"><div><div><h4 class="title" id="xmmime-expectedmediatype-to-java">7.2.1.&nbsp;<code class="literal">xmime:expectedContentType</code> to Java type
            mapping</h4></div></div></div><p>An schema element of type <code class="literal">xs:bas64Binary</code>
            or <code class="literal">xs:hexBinary</code> can be annotated by using
            attribute reference using <a class="link" href="http://www.w3.org/TR/xml-media-types/" target="_top"><code class="literal">xmime:expectedContentType</code></a>
            JAXB 2.0 specification defines
            <code class="literal">xmime:expectedContentType</code> to Java type mapping
            in <a class="xref" href="ch03.html#users-guide-mtom-and-swaref-table-1" title="Table&nbsp;2.&nbsp;xmime:expectedContentType to Java type mapping">Table&nbsp;2, &#8220;<code class="literal">xmime:expectedContentType</code> to Java
                type mapping&#8221;</a>. Here is
            this table:</p><div class="table"><a name="users-guide-mtom-and-swaref-table-1"></a><p class="title"><b>Table&nbsp;2.&nbsp;<code class="literal">xmime:expectedContentType</code> to Java
                type mapping</b></p><div class="table-contents"><table summary="xmime:expectedContentType to Java&#xA;                type mapping" border="1"><colgroup><col width="50%"><col width="50%"></colgroup><thead><tr><th>MIME Type</th><th>Java Type</th></tr></thead><tbody><tr><td><p><code class="literal">image/gif</code></p></td><td><p><code class="literal">java.awt.Image</code></p></td></tr><tr><td><p><code class="literal">image/jpeg</code></p></td><td><p><code class="literal">java.awt.Image</code></p></td></tr><tr><td><p><code class="literal">text/plain</code></p></td><td><p><code class="literal">java.lang.String</code></p></td></tr><tr><td><p><code class="literal">text/xml</code> or
                            <code class="literal">application/xml</code></p></td><td><p><code class="literal">javax.xml.transform.Source</code></p></td></tr><tr><td><p><code class="literal">*/*</code></p></td><td><p><code class="literal">javax.activation.DataHandler</code></p></td></tr></tbody></table></div></div><br class="table-break"><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;element</span> <span class="Identifier">name</span>=<span class="String">"image"</span> <span class="Identifier">type</span>=<span class="String">"base64Binary"</span><span class="ReservedWord">/&gt;</span></pre></div><p>is mapped to <code class="literal">byte[]</code></p><div class="informalexample"><pre class="programlisting">&lt;element name="image" type="base64Binary"
        <span class="bold"><strong>xmime:expectedContentTypes="image/jpeg"</strong></span>
        xmlns:xmime="http://www.w3.org/2005/05/xmlmime"/&gt;</pre></div><p>is mapped to <code class="literal">java.awt.Image</code></p></div><div class="section" title="7.2.2.&nbsp;xmime:contentType schema annotation"><div class="titlepage"><div><div><h4 class="title" id="xmime-contenttype-schema-annotation">7.2.2.&nbsp;<code class="literal">xmime:contentType</code> schema
            annotation</h4></div></div></div><p><a class="link" href="http://www.w3.org/TR/xml-media-types/" target="_top"><code class="literal">xmime:contentType</code></a>
            schema annotation indicates the content-type of an XML element
            content whose type is <code class="literal">xs:base64Binary</code> or
            <code class="literal">xs:hexBinary</code>. The value of the attribute is a
            valid <code class="literal">content-type</code> string (e.g.,
            "<code class="literal">text/xml; charset=utf-16</code>"). This attribute
            specifies the <code class="literal">content-type</code> of the element
            content on which it occurs. This annotation can be primarily used
            to indicate the <code class="literal">Content-Type</code> of binary
            data.</p><p>For example the schema type</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;element</span> <span class="Identifier">name</span>=<span class="String">"TestMtomXmimeContentType"</span> <span class="Identifier">type</span>=<span class="String">"types:PictureType"</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;complexType</span> <span class="Identifier">name</span>=<span class="String">"PictureType"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;simpleContent&gt;</span>
        <span class="ReservedWord">&lt;restriction</span> <span class="Identifier">base</span>=<span class="String">"xmime:base64Binary"</span><span class="ReservedWord">&gt;</span>
            <span class="ReservedWord">&lt;attribute</span> <span class="Identifier">ref</span>=<span class="String">"xmime:contentType"</span> <span class="Identifier">use</span>=<span class="String">"required"</span><span class="ReservedWord">/&gt;</span>
        <span class="ReservedWord">&lt;/restriction&gt;</span>
    <span class="ReservedWord">&lt;/simpleContent&gt;</span>
<span class="ReservedWord">&lt;/complexType&gt;</span></pre></div><p>Here <code class="literal">xmime:base64Binary</code> is defined by
            <a class="link" href="http://www.w3.org/TR/xml-media-types/#schema" target="_top">Describing
            Media Content of Binary Data in XML</a>.</p><p>Gets mapped to PicutreType bean by
            <span class="command"><strong>wsimport</strong></span>:</p><div class="informalexample"><pre class="programlisting"> <code class="literal">PictureType req = new PictureType();
req.setValue(name.getBytes());
req.setContentType("application/xml");</code> </pre></div><p>On the wire this is how it looks:</p><div class="informalexample"><pre class="programlisting"> <code class="literal">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;soapenv:Envelope xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:xsd=" http://www.w3.org/2001/XMLSchema"
        xmlns:ns1=" http://example.org/mtom/data"
        xmlns:ns2="http://www.w3.org/2005/05/xmlmime"&gt;
    &lt;soapenv:Body&gt;
        &lt;ns1:TestMtomXmimeContentTypeResponse
                ns2:contentType="application/xml"&gt;
            &lt;xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include"
                    href="c id:193ed174-d313-4325-8eed-16cc25595e4e@example.org"/&gt;
        &lt;/ns1:TestMtomXmimeContentTypeResponse&gt;
    &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;</code> </pre></div></div><div class="section" title="7.2.3.&nbsp;How to enable MTOM in JAX-WS 2.0"><div class="titlepage"><div><div><h4 class="title" id="how-to-enable-mtom-in-jaxws-2-0">7.2.3.&nbsp;How to enable MTOM in JAX-WS 2.0</h4></div></div></div><p><span class="bold"><strong>Enabling MTOM on
            Server:</strong></span></p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Enable using
                    <code class="literal">@javax.xml.ws.soap.MTOM</code> annotation on
                    the endpoint (SEI) implementation class </p><div class="informalexample"><pre class="programlisting"><span class="Annotation">@javax.xml.ws.soap.MTOM</span>
<span class="Annotation">@WebService(endpointInterface = "mtom.server.Hello")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> HelloImpl <span class="ReservedWord">implements</span> Hello {
    <span class="Comment">// ...</span>
}</pre></div></li></ul></div><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>MTOM can be also be enabled on an endpoint by
                    specifying enable-mtom attribute to true on an endpoint
                    element in <a class="link" href="jaxws-war.html#The_sun-jaxws.xml_File" target="_top">sun-jaxws.xml</a>
                    deployment descriptor. </p><div class="informalexample"><pre class="programlisting"><span class="hl-directive" style="color: maroon">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="ReservedWord">&lt;endpoints</span> <span class="Identifier">xmlns</span>=<span class="String">'http://java.sun.com/xml/ns/jax-ws/ri/runtime'</span>
        <span class="Identifier">version</span>=<span class="String">'2.0'</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;endpoint</span> <span class="Identifier">name</span>=<span class="String">"Mtom"</span>
            <span class="Identifier">implementation</span>=<span class="String">"mtom.server.HelloImpl"</span>
            <span class="Identifier">url-pattern</span>=<span class="String">"/hello"</span>
            <span class="Identifier">enable-mtom</span>=<span class="String">"true"</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;/endpoints&gt;</span></pre></div></li></ul></div><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Enable using <code class="literal">@BindingType</code> on the
                    endpoint (SEI) implementation class </p><div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p><code class="literal">@BindingType(value=javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)</code>
                                will enable MTOM on the deployed endpoint for SOAP
                                1.1 binding</p></li><li class="listitem"><p><code class="literal">@BindingType(value=javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_MTOM_BINDING)</code>
                                will enable MTOM on the deployed endpoint for SOAP
                                1.2 binding</p></li></ul></div></li></ul></div><p><span class="bold"><strong>Enabling MTOM on
            Client:</strong></span></p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>To enable MTOM on client-side, pass
                    javax.xml.ws.soap.MTOMFeature as WebServiceFeature
                    parameter while crating the Proxy or Dispatch. Here is the
                    code snippet from the client <a class="link" href="../samples/mtom/src/mtom/client/MtomApp.java" target="_top">MtomApp.java</a>
                    of the mtom sample: </p><div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p>Hello port = new
                                HelloService().getHelloPort(new MTOMFeature());
                                gives a proxy with MTOM enabled</p></li><li class="listitem"><p>javax.xml.ws.Service.createDispatch(....,new
                                javax.xml.ws.soap.MTOMFeature()) gives a Dispatch
                                instance with MTOM enabled</p></li></ul></div></li><li class="listitem"><p>JAX-WS 2.0 specification has defined API to enable
                    and to check if the MTOM is enabled. </p><div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p>javax.xml.ws.soap.SOAPBinding.setMTOMEnabled(boolean
                                enable) - enable or disable MTOM.</p></li><li class="listitem"><p>javax.xml.ws.soap.SOAPBinding.isMTOMEnabled()
                                - returns true if MTOM is enabled otherwise
                                false.</p></li></ul></div><div class="informalexample"><pre class="programlisting">Hello port = <span class="ReservedWord">new</span> HelloService.getHelloPort();
<span class="Comment">//get the binding and enable mtom</span>
SOAPBinding binding = (SOAPBinding) ((BindingProvider) port).getBinding();
<span class="ReservedWord">boolean</span> mtomEnabled = binding.isMTOMEnabled();

binding.setMTOMEnabled(true);</pre></div></li></ul></div></div><div class="section" title="7.2.4.&nbsp;Attach vs In-line"><div class="titlepage"><div><div><h4 class="title" id="attach-vs-in-line">7.2.4.&nbsp;Attach vs In-line</h4></div></div></div><p>As defined by JAXB 2.0 specification
            <code class="literal">xs:base64Binary</code> and
            <code class="literal">xs:hexBinary</code> mapping to java is
            <code class="literal">byte[]</code>. JAX-WS implementation has set a
            threshold of 1KB of <code class="literal">byte[]</code> size. This threshold
            can be modified using implementation specific property
            <code class="literal">com.sun.xml.ws.developer.JAXWSProperties.MTOM_THRESHOLD_VALUE</code>
            in the <code class="literal">RequestContext</code> on the client side and in
            the <code class="literal">MessageContext</code> on the server side. If the
            <code class="literal">byte[]</code> that is being sent is less than this
            threshold (default is 1KB) then the binary data is base64 encoded
            by JAXB and in lined inside the SOAP Body otherwise the binary
            data is sent as attachment mime part in Multipart/Related package
            and XML infoset for the binary data is XOP encoded by JAXB
            </p><pre class="programlisting">&lt;xop:Include href=...&gt;</pre><p>is
            used to reference the attachment. The XOP encoding and packaging
            is done as per described by the <a class="link" href="http://www.w3.org/TR/xop10/#xop_packages" target="_top">XOP
            packaging rules</a>. The href is the the
            <code class="literal">Content-ID</code> of the attachment and is encoded as
            per CID URI scheme defined in <a class="link" href="http://www.faqs.org/rfcs/rfc2111.html" target="_top">RFC
            2111</a>. <code class="literal">xmime:contentType</code> attribute may
            appear on the element that includes binary data to indicate
            preferred media type as annotated on the corresponding
            schema.</p><div class="section" title="7.2.4.1.&nbsp;How to specify MTOM data Threshold"><div class="titlepage"><div><div><h5 class="title" id="mtom-threshold">7.2.4.1.&nbsp;How to specify MTOM data Threshold</h5></div></div></div><p>Default threshold value for MTOM feature is 0 bytes. You
                can set a threshold value for MTOM by using
                <code class="literal">@MTOM</code> annotation on server-side or using
                MTOMFeature on client-side. Let's say you set MTOM threshold
                as 3000, this serves as hint to JAX-WS when to send binary dat
                as attachments. In this case, JAX-WS will send any byte array
                in the message thats equal to or larger than 3KB as attachment
                and the corresponding XML infoset will be XOP encoded (will
                contain reference to this attachment)</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>On Server-side,
                        <code class="literal">@MTOM(threshold=3000)</code></p></li><li class="listitem"><p>On Client-side, pass
                        <code class="literal">MTOMFeature(3000)</code> as
                        <code class="literal">WebServiceFeature</code> as mentioned in
                        <a class="xref" href="ch03.html#how-to-enable-mtom-in-jaxws-2-0" title="7.2.3.&nbsp;How to enable MTOM in JAX-WS 2.0">Section&nbsp;7.2.3, &#8220;How to enable MTOM in JAX-WS 2.0&#8221;</a>,
                        while creating the proxy/dispatch.</p></li></ul></div></div></div><div class="section" title="7.2.5.&nbsp;MTOM Samples"><div class="titlepage"><div><div><h4 class="title" id="mtom-samples">7.2.5.&nbsp;MTOM Samples</h4></div></div></div><div class="example"><a name="mtom"></a><p class="title"><b>Example&nbsp;1.&nbsp;MTOM Sample - mtom</b></p><div class="example-contents"><p>This is SOAP 1.1 MTOM SampleThis is how the JAX-WS
                generated XOP packaged SOAP message looks on the wire:</p><div class="informalexample"><pre class="programlisting">Content-Type: Multipart/Related; <span class="bold"><strong>start-info="text/xml";</strong></span> <span class="bold"><strong>type="application/xop+xml";</strong></span>
    boundary="----=_Part_0_1744155.1118953559416"
Content-Length: 3453
SOAPAction: ""

    ------=_Part_1_4558657.1118953559446
Content-Type: <span class="bold"><strong>application/xop+xml; type="text/xml";</strong></span> charset=utf-8

&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;soapenv:Body&gt;
        &lt;Detail xmlns="http://example.org/mtom/data"&gt;
            &lt;Photo&gt;RHVrZQ==&lt;/Photo&gt;
            &lt;image&gt;
                <span class="bold"><strong>&lt;xop:Include
                        xmlns:xop="http://www.w3.org/2004/08/xop/include"
                        href="cid:5aeaa450-17f0-4484-b845-a8480c363444@example.org"/&gt;</strong></span>
            &lt;/image&gt;
        &lt;/Detail&gt;
    &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;

------=_Part_1_4558657.1118953559446
Content-Type: image/jpeg
Content-ID: &lt;5aeaa450-17f0-4484-b845-a8480c363444@example.org&gt;

 &#9578;
    &#945; &#9658;JFIF &#9786;&#9787; &#9786; &#9786; &#9608; &#9824;&#9824;
&#9792;&para;
&#9792;&#9794;&#9794;&#9792;&#8595;&#8597;&#8252;&#9788;&para;&#8596;&#8594;&#9660;&#9650;&#8596;&#8594;&#8735;&#8735;
    $.' ",#&#8735;&#8735;(7),01444&#9660;'9=82&lt;.342 &#9608; C&#9786; &#9792;&#9794;&#9792;&#8593;&#8593;2!&#8735;!22222222222222222222222222222222222222222222
    
222222 &#9492; ) &not;&#9829;&#9786;" &#9787;&#9668;&#9786;&#9829;&#9668;&#9786; &#9472; &#9660; &#9786;&#9827;&#9786;&#9786;&#9786;&#9786;&#9786;&#9786;
    &#9786;&#9787;&#9829;&#9830; &#9794; &#9472; &#9569;&#9658; &#9787;&#9786;&#9829;&#9829;&#9787;&#9830;&#9829;&#9827;&#9827;&#9830;&#9830;
    &#9786;}&#9786;&#9787;&#9829; &#9830;&#9668;&#9827;&#8597;!1A&#9824;&#8252;Qa"q&para;2?#B&#9618;&#9524;&sect;R&#9572;&#8801;$3br&eacute;
    
&#9644;&#8616;&#8593;&#8595;&#8594;%&amp;'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz&acirc;&auml;&agrave;&aring;&ccedil;&ecirc;&euml;&egrave;&AElig;&ocirc;&ouml;&ograve;&ucirc;&ugrave;&yuml;&Ouml;&Uuml;&oacute;&uacute;&ntilde;&Ntilde;&ordf;&ordm;&iquest;&#8976;&not;&#9619;&#9474;&#9508;&#9569;&#9570;&#9558;&#9557;&#9571;&#9553;&#9516;&#9500;&#9472;&#9532;&#9566;&#9567;&#9562;&#9556;&#9577;&#9573;&#9561;&#9560;&#9554;&#9555;&#9579;&#9578;&#9496;&#9484;&szlig;&#915;&#960;&#931;&#963;&micro;&#964;&#934;&#920;&#937;&plusmn;&#8805;&#8804;&#8992;&#8993;&divide;&#8776;&deg;&#8729;&middot;
    &#9472;</pre></div><p>Above Photo is inlined binary data because its less than
                1KB and image which is more than 1KB is sent as attachment.
                Here is the associated schema:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;element</span> <span class="Identifier">name</span>=<span class="String">"Detail"</span> <span class="Identifier">type</span>=<span class="String">"types:DetailType"</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;complexType</span> <span class="Identifier">name</span>=<span class="String">"DetailType"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;sequence&gt;</span>
        <span class="Comment">&lt;!-- mapped to byte[] --&gt;</span>
        <span class="ReservedWord">&lt;element</span> <span class="Identifier">name</span>=<span class="String">"Photo"</span> <span class="Identifier">type</span>=<span class="String">"base64Binary"</span><span class="ReservedWord">/&gt;</span>
        <span class="Comment">&lt;!-- mapped tojava.awt.Image --&gt;</span>
        <span class="ReservedWord">&lt;element</span> <span class="Identifier">name</span>=<span class="String">"image"</span> <span class="Identifier">type</span>=<span class="String">"base64Binary"</span>
                <span class="bold"><strong>xmime:expectedContentTypes="image/jpeg"</strong></span>/&gt;
    <span class="ReservedWord">&lt;/sequence&gt;</span>
<span class="ReservedWord">&lt;/complexType&gt;</span></pre></div></div></div><br class="example-break"><div class="example"><a name="mtom-soap12"></a><p class="title"><b>Example&nbsp;2.&nbsp;MTOM Sample - mtom-soap12</b></p><div class="example-contents"><p>This is SOAP 1.2 MTOM Sample. Here is how the JAX-WS
                generated soap message looks on the wire:</p><div class="informalexample"><pre class="programlisting">&lt;element name="image" type="base64Binary" <span class="bold"><strong>xmime:expectedContentTypes="image/jpeg"</strong></span>/&gt;

Content-Type:
    Multipart/Related; <span class="bold"><strong>start-info="application/soap+xml"; type="application/xop+xml";</strong></span>
    boundary="----=_Part_0_1744155.1118960238280"
Content-Length: 1946
SOAPAction: ""

------=_Part_1_4558657.1118960238320
Content-Type: <span class="bold"><strong>application/xop+xml</strong></span>; type="<span class="bold"><strong>application/soap+xml</strong></span>"; charset=utf-8

&lt;soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"&gt;
    &lt;soapenv:Body&gt;
        &lt;Detail xmlns="http://example.org/mtom/data"&gt;
            &lt;Photo&gt;RHVrZQ==&lt;/Photo&gt;
            &lt;image&gt;
                <span class="bold"><strong>&lt;xop:Include
                        xmlns:xop="http://www.w3.org/2004/08/xop/include"
                        href="cid:42a7ee0a-20ee-426b-a135-094d72bc138f@example.org"/&gt;</strong></span>
            &lt;/image&gt;
        &lt;/Detail&gt;
    &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;

------=_Part_1_4558657.1118960238320
Content-Type: application/octet-stream
Content-ID: &lt;42a7ee0a-20ee-426b-a135-094d72bc138f@example.org&gt;

 &#9578; &#945; &#9658;JFIF &#9786;&#9787; &#9786; &#9786; &#9608; &#9824;&#9824;
&#9792;&para;

    &#9792;&#9794;&#9794;&#9792;&#8595;&#8597;&#8252;&#9788;&para;&#8596;&#8594;&#9660;&#9650;&#8596;&#8594;&#8735;&#8735;
    $.' ",#&#8735;&#8735;(7),01444&#9660;'9=82&lt;.342 &#9608; C&#9786; &#9792;&#9794;&#9792;&#8593;&#8593;2!&#8735;!22222222222222222222222222222222222222222222
    
222222 &#9492; ' )&#9829;&#9786;" &#9787;&#9668;&#9786;&#9829;&#9668;&#9786; &#9472; &#9660; &#9786;&#9827;&#9786;&#9786;&#9786;&#9786;&#9786;&#9786;
    &#9786;&#9787;&#9829;&#9830; &#9794; &#9472; &#9569;&#9658; &#9787;&#9786;&#9829;&#9829;&#9787;&#9830;&#9829;&#9827;&#9827;&#9830;&#9830;
    &#9786;}&#9786;&#9787;&#9829; &#9830;&#9668;&#9827;&#8597;!1A&#9824;&#8252;Qa"q&para;2?#B&#9618;&#9524;&sect;R&#9572;&#8801;$3br&eacute;
    
&#9644;&#8616;&#8593;&#8595;&#8594;%&amp;'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz&acirc;&auml;&agrave;&aring;&ccedil;&ecirc;&euml;&egrave;&AElig;&ocirc;&ouml;&ograve;&ucirc;&ugrave;&yuml;&Ouml;&Uuml;&oacute;&uacute;&ntilde;&Ntilde;&ordf;&ordm;&iquest;&#8976;&not;&#9619;&#9474;&#9508;&#9569;&#9570;&#9558;&#9557;&#9571;&#9553;&#9516;&#9500;&#9472;&#9532;&#9566;&#9567;&#9562;&#9556;&#9577;&#9573;&#9561;&#9560;&#9554;&#9555;&#9579;&#9578;&#9496;&#9484;&szlig;&#915;&#960;&#931;&#963;&micro;&#964;&#934;&#920;&#937;&plusmn;&#8805;&#8804;&#8992;&#8993;&divide;&#8776;&deg;&#8729;&middot;
    &#9472;
 &#9660;&#9786; &#9829;&#9786;&#9786;&#9786;&#9786;&#9786;&#9786;&#9786;&#9786;&#9786; &#9786;&#9787;&#9829;&#9830;</pre></div></div></div><br class="example-break"></div></div><div class="section" title="7.3.&nbsp;swaRef"><div class="titlepage"><div><div><h3 class="title" id="swaref">7.3.&nbsp;swaRef</h3></div></div></div><p><a class="link" href="http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html" target="_top">WS-I
        Attachment Profile 1.0</a> defines mechanism to reference MIME
        attachment parts using <a class="link" href="http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html#Referencing_Attachments_from_the_SOAP_Envelope" target="_top">swaRef</a>.
        In this mechanism the content of XML element of type <a class="link" href="http://ws-i.org/profiles/basic/1.1/xsd/" target="_top"><code class="literal">wsi:swaRef</code></a>
        is sent as MIME attachment and the element inside SOAP Body holds the
        reference to this attachment in the CID URI scheme as defined by <a class="link" href="http://www.faqs.org/rfcs/rfc2111.html" target="_top">RFC
        2111</a>.</p><div class="section" title="7.3.1.&nbsp;swaRef in JAX-WS 2.0"><div class="titlepage"><div><div><h4 class="title" id="swaref-in-jaxws-2-0">7.3.1.&nbsp;swaRef in JAX-WS 2.0</h4></div></div></div><p>JAXB 2.0 defines mapping of <code class="literal">wsi:swaRef</code>
            schema type to javax.activation.DataHandler. An application will
            construct the DataHandler with the data and the appropriate MIME
            type and JAX-WS will coordinate with JAXB and SAAJ to send it as
            attachment MIME part.</p></div><div class="section" title="7.3.2.&nbsp;How to use swaRef"><div class="titlepage"><div><div><h4 class="title" id="how-to-use-swaref">7.3.2.&nbsp;How to use swaRef</h4></div></div></div><p>An XML element of type <code class="literal">wsi:swaRef</code> is
            mapped to a DataHandler and is sent as attachment over the wire.
            For example,</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;element</span> <span class="Identifier">name</span>=<span class="String">"claimForm"</span> <span class="Identifier">type</span>=<span class="String">"</span><span class="bold"><strong>wsi:swaRef</strong></span>"
        xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd"/&gt;</pre></div><p>will be sent over the wire as :</p><div class="informalexample"><pre class="programlisting">Content-Type: Multipart/Related; start-info="text/xml"; type="application/xop+xml";
    boundary="----=_Part_4_32542424.1118953563492"
Content-Length: 1193
SOAPAction: ""

------=_Part_5_32550604.1118953563502
Content-Type: application/xop+xml; type="text/xml"; charset=utf-8

&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;soapenv:Body&gt;
        &lt;claimForm xmlns="http://example.org/mtom/data"&gt;
            <span class="bold"><strong>cid:b0a597fd-5ef7-4f0c-9d85-6666239f1d25@example.jaxws.sun.com</strong></span>
        &lt;/claimForm&gt;
    &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;

------=_Part_5_32550604.1118953563502
Content-Type: application/xml
Content-ID: &lt;<span class="bold"><strong>b0a597fd-5ef7-4f0c-9d85-6666239f1d25@example.jaxws.sun.com</strong></span>&gt;

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;application xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocaption="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/application_1_4.xsd" version="1.4"&gt;
    &lt;display-name&gt;Simple example of application&lt;/display-name&gt;
    &lt;description&gt;Simple example&lt;/description&gt;
    &lt;module&gt;
        &lt;ejb&gt;ejb1.jar&lt;/ejb&gt;
    &lt;/module&gt;
    &lt;module&gt;
        &lt;ejb&gt;ejb2.jar&lt;/ejb&gt;
    &lt;/module&gt;
    &lt;module&gt;
        &lt;web&gt;
            &lt;web-uri&gt;web.war&lt;/web-uri&gt;
            &lt;context-root&gt;web&lt;/context-root&gt;
        &lt;/web&gt;
    &lt;/module&gt;
&lt;/application&gt;</pre></div></div><div class="section" title="7.3.3.&nbsp;swaRef Sample"><div class="titlepage"><div><div><h4 class="title" id="swaref-samples">7.3.3.&nbsp;swaRef Sample</h4></div></div></div><p>Refer to <span class="application">swaRef</span> sample
            <code class="literal">testSwaRef()</code> method in <a class="link" href="../samples/mime/src/mime/client/MimeApp.java" target="_top">MimeApp.java.</a></p></div></div></div><div lang="en" class="section" title="8.&nbsp;SOAP 1.2"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-soap-1-2">8.&nbsp;SOAP 1.2</h2></div></div></div><div class="section" title="8.1.&nbsp;Introduction"><div class="titlepage"><div><div><h3 class="title" id="section-94073181229507">8.1.&nbsp;Introduction</h3></div></div></div><p>The default binding supported by JAX-WS 2.0 is SOAP 1.1 over
        HTTP. With this release we have added <span class="bold"><strong>SOAP 1.2
        binding over HTTP</strong></span> support into JAX-WS 2.0. This document
        describes how SOAP 1.2 binding can be applied to an endpoint and how
        it can be used on the client side in the case of proxy port. To enable
        SOAP 1.2 support in the <code class="literal">Dispatch</code> client please
        refer to the <code class="literal">Dispatch</code> documents.</p></div><div class="section" title="8.2.&nbsp;SOAP 1.2 Endpoint"><div class="titlepage"><div><div><h3 class="title" id="section-627071591090577">8.2.&nbsp;SOAP 1.2 Endpoint</h3></div></div></div><p>To enable SOAP 1.2 binding on an endpoint. You would need to set
        binding attribute value in <a class="link" href="jaxws-war.html#The_sun-jaxws.xml_File" target="_top">sun-jaxws.xml</a>
        to SOAP 1.2 HTTP binding value as specified by
        <code class="literal">javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING</code>
        which is: "<a class="link" href="http://www.w3.org/2003/05/soap/bindings/HTTP/" target="_top">http://www.w3.org/2003/05/soap/bindings/HTTP/</a>"
        or "<a class="link" href="http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/" target="_top">http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/</a>"</p><p>Here is the <code class="filename">sun-jaxws.xml</code> from
        <span class="application">fromjava-soap1.2</span> sample:</p><div class="informalexample"><pre class="programlisting"><span class="hl-directive" style="color: maroon">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="ReservedWord">&lt;endpoints</span> <span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/jax-ws/ri/runtime"</span>
        <span class="Identifier">version</span>=<span class="String">"2.0"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;endpoint</span> <span class="Identifier">name</span>=<span class="String">"fromjava-soap12"</span>
            <span class="Identifier">implementation</span>=<span class="String">"fromjava_soap12.server.AddNumbersImpl"</span>
            <span class="Identifier">binding</span>=<span class="String">"http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/
            url-pattern="</span><span class="ReservedWord">/a</span>ddnumbers"/&gt;
<span class="ReservedWord">&lt;/endpoints&gt;</span></pre></div><p>JAX-WS 2.0 generates WSDL on the fly when requested by a client.
        If this binding attribute is present and is equal to SOAP 1.2 HTTP
        binding WSDL with SOAP 1.2 binding is generated. Based on this binding
        descriptor JAX-WS runtime configures itself to handle SOAP 1.2
        messages.</p><p>Notice that the binding id "<a class="link" href="http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/" target="_top">http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/</a>"
        is not a standard binding id. If you use SOAP 1.2 binding id "<a class="link" href="http://www.w3.org/2003/05/soap/bindings/HTTP/" target="_top">http://www.w3.org/2003/05/soap/bindings/HTTP/</a>"
        defined by JAX-WS, still the endpoint is configured to use SOAP 1.2
        binding, except that a wsdl will not be generated on the fly.</p><p>Alternatively, you can specify the binding through
        <code class="literal">@BindingType</code> annotation in the implementation class
        to use SOAP 1.2 binding. Here is an example from the
        <span class="application">fromjava_soap12</span> sample.</p><div class="informalexample"><pre class="programlisting"><span class="Annotation">@WebService</span>
<span class="Annotation">@BindingType(value = "http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl {

    <span class="Comment">/**
     * @param number1
     * @param number2
     * @return The sum
     * @throws AddNumbersException if any of the numbers to be added is
     *                             negative.
     */</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            AddNumbersException {
        <span class="ReservedWord">if</span> (number1 &lt; <span class="Numeric">0</span> || number2 &lt; <span class="Numeric">0</span>) {
            <span class="ReservedWord">throw</span> <span class="ReservedWord">new</span> AddNumbersException(<span class="String">"Negative number cant be added "</span> +
                    <span class="String">"!"</span>, <span class="String">"Numbers: "</span> + number1 + <span class="String">", "</span> + number2);
        }
        <span class="ReservedWord">return</span> number1 + number2;
    }

}</pre></div><p>The commandline <a class="xref" href="ch04.html#tools-wsgen" title="4.&nbsp;wsgen"><span class="command"><strong>wsgen</strong></span></a> and the equivalent ant task can be used to
        generate SOAP 1.1 (default) or SOAP 1.2 WSDL. The binding information
        should be passed using <code class="literal">-wsdl:protocol</code>
        switch.</p></div><div class="section" title="8.3.&nbsp;Client"><div class="titlepage"><div><div><h3 class="title" id="section-696486497021005">8.3.&nbsp;Client</h3></div></div></div><p>On the client there is nothing special that has to be done.
        JAX-WS runtime looks into the WSDL to determine the binding being used
        and configures itself accordingly. <a class="xref" href="ch04.html#tools-wsimport" title="2.&nbsp;wsimport"><span class="command"><strong>wsimport</strong></span></a> command line tool or
        <span class="command"><strong>wsimport</strong></span> ant task can be used to import the WSDL
        and to generated the client side artifacts.</p></div><div class="section" title="8.4.&nbsp;Samples"><div class="titlepage"><div><div><h3 class="title" id="section-7037754311590527">8.4.&nbsp;Samples</h3></div></div></div><p>There are 2 samples bundled with this release</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><span class="application">fromwsdl-soap12</span> - shows SOAP
                1.2 endpoint developed starting from wsdl</p></li><li class="listitem"><p><span class="application">fromjava-soap12</span> - shows SOAP
                1.2 endpoint developed starting from Java</p></li></ul></div><p>A SOAP 1.2 message generated by JAX-WS:</p><div class="informalexample"><pre class="programlisting">Content-Type: application/soap+xml; charset=utf-8
Content-Length: 178
SOAPAction: ""

&lt;soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"&gt;
    &lt;soapenv:Body&gt;
        &lt;addNumbers xmlns="http://duke.example.org"&gt;
            &lt;arg0&gt;-10&lt;/arg0&gt;
            &lt;arg1&gt;20&lt;/arg1&gt;
        &lt;/addNumbers&gt;
    &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;</pre></div><p>A SOAP 1.2 Fault message generated by JAX-WS:</p><div class="informalexample"><pre class="programlisting">Content-Type:application/soap+xml; charset=utf-8
Content-Length: 476
SOAPAction: ""

&lt;soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"&gt;
    &lt;soapenv:Body&gt;
        &lt;soapenv:Fault&gt;
            &lt;soapenv:Code&gt;
                &lt;soapenv:Value&gt;
                    soapenv:Sender
                &lt;/soapenv:Value&gt;
            &lt;/soapenv:Code&gt;
            &lt;soapenv:Reason&gt;
                &lt;soapenv:Text xml:lang="en"&gt;
                    Negative number cant be added!
                &lt;/soapenv:Text&gt;
            &lt;/soapenv:Reason&gt;
            &lt;soapenv:Detail&gt;
                &lt;AddNumbersFault xmlns="http://duke.example.org"&gt;
                    &lt;faultInfo&gt;Numbers: -10, 20&lt;/faultInfo&gt;
                    &lt;message&gt;Negative number cant be added!&lt;/message&gt;
                &lt;/AddNumbersFault&gt;
            &lt;/soapenv:Detail&gt;
        &lt;/soapenv:Fault&gt;
    &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;</pre></div></div></div><div lang="en" class="section" title="9.&nbsp;WSDL Customization"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-wsdl-customization">9.&nbsp;WSDL Customization</h2></div></div></div><p>The JAX-WS 2.0 specification defines standard XML-based
    customization for WSDL to Java mapping and to control certain features.
    These customizations, or <span class="emphasis"><em>binding declarations</em></span>, can
    customize almost all WSDL components that can be mapped to Java, such as
    the service endpoint interface class, method name, parameter name,
    exception class, etc. The other important thing you can do with these
    binding declarations is control certain features, such as asynchrony,
    provider, wrapper style, and additional headers. For example, a client
    application can enable asynchrony for a particular operation in a
    <code class="literal">portType</code> or all operations in a
    <code class="literal">portType</code> or all <code class="literal">portType</code> operations
    defined in the WSDL file.</p><p>The JAX-RPC 1.1 specification did not define a standard
    customization architecture. However JAX-RPC 1.x SI had limited WSDL to
    Java customization support. It allowed a JAX-RPC 1.x application
    to:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Define a package where Java artifacts mapped from a WSDL
            file will be generated.</p></li><li class="listitem"><p>Customize the package for the value classes mapped from the
            imported XML schema by the WSDL document.</p></li><li class="listitem"><p>Customize handler chains.</p></li></ul></div><p>But these customizations were not portable and could not be used
    across other JAX-RPC implementations. JAX-WS RI 2.2.7 provides
    complete support for all the binding declarations defined by the
    specification.</p><div class="section" title="9.1.&nbsp;Declaring Customizations"><div class="titlepage"><div><div><h3 class="title" id="declaring-customizations">9.1.&nbsp;Declaring Customizations</h3></div></div></div><p>All the binding declaration elements live in
        <code class="literal">http://java.sun.com/xml/ns/jaxws</code> namespace. There
        are two ways to specify binding declarations. In the first approach,
        all binding declarations pertaining to a given WSDL document are
        grouped together in a standalone document, called an
        <span class="emphasis"><em>external binding file</em></span>. The second approach
        consists of embedding binding declarations directly inside a WSDL
        document. In either case, the <code class="literal">jaxws:bindings</code>
        element is used as a container for JAX-WS binding declarations. The
        <code class="literal">jaxws</code> prefix maps to the
        <code class="literal">http://java.sun.com/xml/ns/jaxws</code> namespace.</p><div class="section" title="9.1.1.&nbsp;External Binding Declaration"><div class="titlepage"><div><div><h4 class="title" id="external-binding-declaration">9.1.1.&nbsp;External Binding Declaration</h4></div></div></div><p>External binding files are semantically equivalent to
            embedded binding declarations. When <span class="command"><strong>wsimport</strong></span>
            processes the WSDL document for which there is an external binding
            file, it internalizes the binding declarations defined in the
            external binding file on the nodes in the WSDL document they
            target using the <code class="literal">wsdlLocation</code> attribute. The
            embedded binding declarations can exist in a WSDL file and an
            external binding file targeting that WSDL, but
            <span class="command"><strong>wsimport</strong></span> may give an error if, upon embedding
            the binding declarations defined in the external binding files,
            the resulting WSDL document contains conflicting binding
            declarations.</p><div class="section" title="9.1.1.1.&nbsp;Root Binding Element"><div class="titlepage"><div><div><h5 class="title" id="root-binding-element">9.1.1.1.&nbsp;Root Binding Element</h5></div></div></div><p>The <code class="literal">jaxws:bindings</code> declaration
                appears as the root of all other binding declarations. This
                top-level <code class="literal">jaxws:bindings</code> element must
                specify the location of the WSDL file as a URI in the value of
                <code class="literal">wsdlLocation</code> attribute.</p><p>Its important that the <code class="literal">wsdlLocation</code>
                attribute on the root <code class="literal">jaxws:bindings</code>
                declaration is same as the WSDL location URI given to
                <span class="command"><strong>wsimport</strong></span>.</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;jaxws:bindings</span>
        <span class="Identifier">wsdlLocation</span>=<span class="String">"http://localhost:8080/jaxws-external-customize/addnumbers?WSDL"</span>
        <span class="Identifier">jaxws:xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/jaxws"</span><span class="ReservedWord">&gt;</span>
    
    ...

<span class="ReservedWord">&lt;/jaxws:bindings&gt;</span></pre></div></div><div class="section" title="9.1.1.2.&nbsp;Child Binding Elements"><div class="titlepage"><div><div><h5 class="title" id="child-binding-elements">9.1.1.2.&nbsp;Child Binding Elements</h5></div></div></div><p>The root <code class="literal">jaxws:bindings</code> element may
                contain child <code class="literal">jaxws:bindings</code> elements. In
                this case the child <code class="literal">jaxws:bindings</code> element
                must carry an XPath expression in the node attribute to refer
                to the WSDL node it customizes.</p><p>Here is an excerpt from an external binding file <a class="link" href="../samples/external-customize/etc/custom-client.xml" target="_top">custom-client.xml</a>
                in the <code class="literal">external-customize</code> sample:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;jaxws:bindings</span>
        <span class="Identifier">wsdlLocation</span>=<span class="String">"http://localhost:8080/jaxws-external-customize/addnumbers?WSDL"</span>
        <span class="Identifier">jaxws:xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/jaxws"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;jaxws:bindings</span> <span class="Identifier">node</span>=<span class="String">"wsdl:definitions"</span>
            <span class="Identifier">xmlns:wsdl</span>=<span class="String">"http://schemas.xmlsoap.org/wsdl/"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;jaxws:package</span> <span class="Identifier">name</span>=<span class="String">"external_customize.client"</span><span class="ReservedWord">/&gt;</span>
        
        ...
        
    <span class="ReservedWord">&lt;/jaxws:bindings&gt;</span>
<span class="ReservedWord">&lt;/jaxws:bindings&gt;</span></pre></div><p>In this example the child
                <code class="literal">jaxws:bindings</code> applies package
                customization. An XPath expression in the node attribute
                refers to the root node of the WSDL document, which is
                <code class="literal">wsdl:definitions</code> and declares the package
                <code class="literal">external_customize.client</code> for all the
                generated Java classes mapped from the WSDL file.</p></div></div><div class="section" title="9.1.2.&nbsp;Embedded Binding Declarations"><div class="titlepage"><div><div><h4 class="title" id="embedded-binding-declarations">9.1.2.&nbsp;Embedded Binding Declarations</h4></div></div></div><p>Embedded binding declarations directly inside the WSDL
            follow different rules compared to the binding declarations
            declared in the external binding file. Here are some important
            facts and rules as defined in the JAX-WS 2.0 specification:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>An embedded binding declaration is specified by
                    using the <code class="literal">jaxws:bindings</code> element as a
                    WSDL extension inside the wsdl node that is to be
                    customized.</p></li><li class="listitem"><p>When a <code class="literal">jaxws:bindings</code> element is
                    used as a WSDL extension, the&nbsp;
                    <code class="literal">jaxws:bindings</code> element should not have
                    node attribute (the node attribute is only used in
                    external customization file to scope the custmization to a
                    wsdl element).</p></li><li class="listitem"><p>A binding declaration embedded in a WSDL can only
                    affect the WSDL element it extends.</p></li></ul></div><p>Here's an example of embedded binding declarations in the
            WSDL <code class="literal">AddNumbers.wsdl</code> from the
            <code class="literal">inline-customize</code> sample:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;wsdl:portType</span> <span class="Identifier">name</span>=<span class="String">"AddNumbersImpl"</span><span class="ReservedWord">&gt;</span>
    <span class="Comment">&lt;!-- wsdl:portType customizations --&gt;</span>
    <span class="ReservedWord">&lt;jaxws:bindings</span> <span class="Identifier">xmlns:jaxws</span>=<span class="String">"http://java.sun.com/xml/ns/jaxws"</span><span class="ReservedWord">&gt;</span>
        <span class="Comment">&lt;!-- rename the generated SEI from AddNumbersImpl to MathUtil --&gt;</span>
        <span class="ReservedWord">&lt;jaxws:class</span> <span class="Identifier">name</span>=<span class="String">"MathUtil"</span><span class="ReservedWord">/&gt;</span>
        ...
    <span class="ReservedWord">&lt;/jaxws:bindings&gt;</span>
    <span class="ReservedWord">&lt;wsdl:operation</span> <span class="Identifier">name</span>=<span class="String">"addNumber"</span><span class="ReservedWord">&gt;</span>
        ...
    <span class="ReservedWord">&lt;/wsdl:operation&gt;</span>
<span class="ReservedWord">&lt;/wsdl:portType&gt;</span></pre></div><p>The above WSDL file excerpt shows the
            <code class="literal">wsdl:portType</code> customization.
            <code class="literal">jaxws:bindings</code> appears as extension element of
            <code class="literal">portType</code>. It customizes the class name of the
            generated service endpoint interface. Without this customization,
            or by default, the service endpoint interface class is named after
            the <code class="literal">wsdl:portType</code> name. The binding declaration
            <code class="literal">jaxws:class</code> customizes the generated class to
            be named <code class="literal">MathUtil</code> instead of
            <code class="literal">AddNumberImpl</code>.</p><p>In the following section, all the possible standard
            customizations and their scope is described. Global customizations
            can be specified under &lt;wsdl:definitions&gt; element and other
            customizations can be specified &nbsp;under&nbsp;the node of its
            scope.</p></div></div><div class="section" title="9.2.&nbsp;Standard Customizations"><div class="titlepage"><div><div><h3 class="title" id="standard-customizations">9.2.&nbsp;Standard Customizations</h3></div></div></div><p>This section provides the details of all the possible WSDL
        binding declarations.</p><div class="section" title="9.2.1.&nbsp;Global bindings"><div class="titlepage"><div><div><h4 class="title" id="global-bindings">9.2.1.&nbsp;Global bindings</h4></div></div></div><p>The global customizations are the customizations that
            applies to the entire scope of <code class="literal">wsdl:definition</code>
            in the wsdl referenced by the root
            <code class="literal">jaxws:bindings@wsdlLocation.Following</code>
            customizations have the global scopes:</p><pre class="programlisting"><span class="ReservedWord">&lt;jaxws:package</span> <span class="Identifier">name</span>=<span class="String">"..."</span><span class="ReservedWord">/&gt;</span></pre><pre class="programlisting"><span class="ReservedWord">&lt;jaxws:enableWrapperStyle/&gt;</span></pre><pre class="programlisting"><span class="ReservedWord">&lt;jaxws:enableAsyncMapping/&gt;</span></pre><p>These
            can appear as direct child of the <a class="xref" href="ch03.html#root-binding-element" title="9.1.1.1.&nbsp;Root Binding Element">Root Binding Element</a>
            declarations in the external customization file. For
            example:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;bindings</span> <span class="Identifier">xmlns:wsdl</span>=<span class="String">"http://schemas.xmlsoap.org/wsdl/"</span>
        <span class="Identifier">wsdlLocation</span>=<span class="String">"http://localhost:8080/jaxws-external-customize/addnumbers?WSDL"</span>
        <span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/jaxws"</span><span class="ReservedWord">&gt;</span>
    
    <span class="ReservedWord">&lt;package</span> <span class="Identifier">name</span>=<span class="String">"external_customize.client"</span><span class="ReservedWord">/&gt;</span>
    <span class="ReservedWord">&lt;enableWrapperStyle&gt;</span>true<span class="ReservedWord">&lt;/enableWrapperStyle&gt;</span>
    <span class="ReservedWord">&lt;enableAsyncMapping&gt;</span>false<span class="ReservedWord">&lt;/enableAsyncMapping&gt;</span>
<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div><p>In embedded usage, the global customization can be specified
            under <code class="literal">&lt;wsdl:definitions&gt;</code> node of the
            wsdl.</p></div><div class="section" title="9.2.2.&nbsp;Package Customization"><div class="titlepage"><div><div><h4 class="title" id="package-customization">9.2.2.&nbsp;Package Customization</h4></div></div></div><p>By default <span class="command"><strong>wscompile</strong></span> generates WSDL
            artifacts in a package computed from the WSDL
            <code class="literal">targetNamespace</code>. For example, a WSDL file with
            the <code class="literal">targetNamespace</code>
            <code class="literal">http://duke.example.org</code> without any package
            customization will be mapped to the <code class="literal">org.duke</code>
            package. To customize the default package mapping you would use a
            <code class="literal">jaxws:package</code> customization on the
            <code class="literal">wsdl:definitions</code> node or it can directly appear
            inside the top level bindings element.</p><p>An important thing to note is that <code class="option">-p</code>
            option on commandline <span class="command"><strong>wsimport.sh</strong></span> tool (package
            attribute on <span class="command"><strong>wsimport</strong></span> ant task), overrides the
            <code class="literal">jaxws:package</code> customization,it also overrides
            the schema package customization specified using jaxb schema
            customization.</p><p>For example:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;bindings</span> <span class="Identifier">xmlns:wsdl</span>=<span class="String">"http://schemas.xmlsoap.org/wsdl/"</span>
        <span class="Identifier">wsdlLocation</span>=<span class="String">"http://localhost:8080/jaxws-external-customize/addnumbers?WSDL"</span>
        <span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/jaxws"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;package</span> <span class="Identifier">name</span>=<span class="String">"external_customize.client"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;javadoc&gt;</span>Mathutil package<span class="ReservedWord">&lt;/javadoc&gt;</span>
    <span class="ReservedWord">&lt;/package&gt;</span>
    
    ...
    
<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div><p>or</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;bindings</span> <span class="Identifier">xmlns:wsdl</span>=<span class="String">"http://schemas.xmlsoap.org/wsdl/"</span>
        <span class="Identifier">wsdlLocation</span>=<span class="String">"http://localhost:8080/jaxws-external-customize/addnumbers?WSDL"</span>
        <span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/jaxws"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;bindings</span> <span class="Identifier">node</span>=<span class="String">"wsdl:definitions"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;package</span> <span class="Identifier">name</span>=<span class="String">"external_customize.client"</span><span class="ReservedWord">&gt;</span>
            <span class="ReservedWord">&lt;javadoc&gt;</span>Mathutil package<span class="ReservedWord">&lt;/javadoc&gt;</span>
        <span class="ReservedWord">&lt;/package&gt;</span>
        
        ...
        
    <span class="ReservedWord">&lt;/bindings&gt;</span>
    
    ...
    
<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div></div><div class="section" title="9.2.3.&nbsp;Wrapper Style"><div class="titlepage"><div><div><h4 class="title" id="wrapper-style">9.2.3.&nbsp;Wrapper Style</h4></div></div></div><p><span class="command"><strong>wsimport</strong></span> by default applies wrapper style
            rules to the abstract operation defined in the
            <code class="literal">wsdl:portType</code>, and if an operation qualifies
            the Java method signature is generated accordingly. Wrapper style
            Java method generation can be disabled by using
            <code class="literal">jaxws:enableWrapperStyle</code>.</p><p><code class="literal">jaxws:enableWrapperStyle</code> can appear on
            the toplevel bindings element (with
            <code class="literal">@wsdlLocation</code> attribute), it can also appear on
            the following target nodes:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><code class="literal">wsdl:definitions</code> global scope,
                    applies to all the <code class="literal">wsdl:operations</code> of
                    all <code class="literal">wsdl:portType</code> attributes</p></li><li class="listitem"><p><code class="literal">wsdl:portType</code> applies to all the
                    <code class="literal">wsdl:operations</code> in the
                    <code class="literal">portType</code></p></li><li class="listitem"><p><code class="literal">wsdl:operation</code> applies to only
                    this <code class="literal">wsdl:operation</code></p></li></ul></div><p>For example:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;bindings</span> <span class="Identifier">xmlns:wsdl</span>=<span class="String">"http://schemas.xmlsoap.org/wsdl/"</span>
        <span class="Identifier">wsdlLocation</span>=<span class="String">"http://localhost:8080/jaxws-external-customize/addnumbers?WSDL"</span>
        <span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/jaxws"</span><span class="ReservedWord">&gt;</span>
    
    <span class="Comment">&lt;!-- applies to wsdl:definitions node, that would mean the entire wsdl --&gt;</span>
    <span class="ReservedWord">&lt;enableWrapperStyle&gt;</span>true<span class="ReservedWord">&lt;/enableWrapperStyle&gt;</span>
    <span class="Comment">&lt;!-- wsdl:portType operation customization --&gt;</span>
    <span class="ReservedWord">&lt;bindings</span>
            <span class="Identifier">node</span>=<span class="String">"wsdl:definitions/wsdl:portType[@name='AddNumbersImpl']/wsdl:operation[@name='addNumbers']"</span><span class="ReservedWord">&gt;</span>
        <span class="Comment">&lt;!-- change java method name from addNumbers() to add() --&gt;</span>
        <span class="ReservedWord">&lt;enableWrapperStyle&gt;</span>false<span class="ReservedWord">&lt;/enableWrapperStyle&gt;</span>
        
        ...
        
    <span class="ReservedWord">&lt;/bindings&gt;</span>
    
    ...
    
<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div><p>In the example above the wrapper style is disabled for the
            <code class="literal">addNumbers</code> operation in
            <code class="literal">AddNumbersImpl</code> <code class="literal">portType</code>
            .This is because <span class="command"><strong>wsimport</strong></span> processes this
            binding in the following order: first
            <code class="literal">wsdl:operation</code>, then its parent
            <code class="literal">wsdl:portType</code>, and finally
            <code class="literal">wsdl:definitions</code>. Here
            <code class="literal">wsdl:operation</code> <code class="literal">addNumbers</code>
            has this customization disabled so this is what is applied by
            <span class="command"><strong>wsimport</strong></span> to generate a bare Java method
            signature.</p></div><div class="section" title="9.2.4.&nbsp;Asynchrony"><div class="titlepage"><div><div><h4 class="title" id="asynchrony">9.2.4.&nbsp;Asynchrony</h4></div></div></div><p>A client application can use the
            <code class="literal">jaxws:enableAsyncMapping</code> binding declaration so
            that <span class="command"><strong>wsimport</strong></span> will generate async polling and
            callback operations along with the normal synchronous method when
            it compiles a WSDL file.</p><p>It has the same target nodes as the wrapper style binding
            declaration described above in section 2.2.</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><code class="literal">wsdl:definitions</code> or toplevel
                    bindings element: global scope, applies to all the
                    <code class="literal">wsdl:operations</code> of all
                    <code class="literal">wsdl:portType</code></p></li><li class="listitem"><p><code class="literal">wsdl:portType</code> applies to all the
                    <code class="literal">wsdl:operations</code> in the
                    <code class="literal">portType</code></p></li><li class="listitem"><p><code class="literal">wsdl:operation</code> applies to only
                    this <code class="literal">wsdl:operation</code></p></li></ul></div><p>Example :</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;bindings</span> <span class="Identifier">xmlns:wsdl</span>=<span class="String">"http://schemas.xmlsoap.org/wsdl/"</span>
        <span class="Identifier">wsdlLocation</span>=<span class="String">"http://localhost:8080/jaxws-external-customize/addnumbers?WSDL"</span>
        <span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/jaxws"</span><span class="ReservedWord">&gt;</span>
    
    <span class="Comment">&lt;!-- applies to wsdl:definitions node, that would mean the entire wsdl --&gt;</span>
    <span class="ReservedWord">&lt;enableAsyncMapping&gt;</span>false<span class="ReservedWord">&lt;/enableAsyncMapping&gt;</span>
    <span class="Comment">&lt;!-- wsdl:portType operation customization --&gt;</span>
    <span class="ReservedWord">&lt;bindings</span>
            <span class="Identifier">node</span>=<span class="String">"wsdl:definitions/wsdl:portType[@name='AddNumbersImpl']/wsdl:operation[@name='addNumbers']"</span><span class="ReservedWord">&gt;</span>
        <span class="Comment">&lt;!-- change java method name from addNumbers() to add() --&gt;</span>
        <span class="ReservedWord">&lt;enableAsyncMapping&gt;</span>true<span class="ReservedWord">&lt;/enableAsyncMapping&gt;</span>

        ...

    <span class="ReservedWord">&lt;/bindings&gt;</span>

    ...

<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div><p>In the above example <span class="command"><strong>wsimport</strong></span> will
            generate async polling and callback methods for the
            <code class="literal">addNumbers</code> operation. In the
            <code class="literal">wsdl:definition</code> node, the async customization
            is disabled or false but the <code class="literal">wsdl:operation</code>
            node has it enabled or true, and so <span class="command"><strong>wsimport</strong></span>
            generates the async methods of the
            <code class="literal">wsdl:operation</code>
            <code class="literal">addNumbers</code>.</p><p>This is how the generated signatures look (annotations are
            removed from synchronous method for reading simplicity):</p><div class="informalexample"><pre class="programlisting"><span class="Comment">//synchronous method</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2)
        <span class="ReservedWord">throws</span> org.duke.AddNumbersFault_Exception, java.rmi.RemoteException;

<span class="Comment">//async polling Method</span>
<span class="ReservedWord">public</span> Response&lt;AddNumbersResponse&gt; addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2);

<span class="Comment">//async callback Method</span>
<span class="ReservedWord">public</span> Future&lt;?&gt; addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2,
                            AsyncHandler&lt;AddNumbersResponse&gt;);

...</pre></div></div><div class="section" title="9.2.5.&nbsp;The Provider Interface"><div class="titlepage"><div><div><h4 class="title" id="provider-interface">9.2.5.&nbsp;The Provider Interface</h4></div></div></div><p>By default the value of <code class="literal">jaxws:provider</code>
            binding is false. That is, provider interface generation is
            disabled. In order to mark a port as provider interface this
            binding declaration should refer to the
            <code class="literal">wsdl:port</code> node using an XPath expression.
            Please note that provider binding declaration applies only when
            developing a server starting from a WSDL file.</p></div><div class="section" title="9.2.6.&nbsp;Class Customization"><div class="titlepage"><div><div><h4 class="title" id="class-customization">9.2.6.&nbsp;Class Customization</h4></div></div></div><p>The generated class for <code class="literal">wsdl:portType</code>,
            <code class="literal">wsdl:fault</code>,
            <code class="literal">soap:headerfault</code>, and
            <code class="literal">wsdl:server</code> can be customized using the
            <code class="literal">jaxws:class</code> binding declaration. Refer to the
            external binding declaration file
            <code class="literal">custom-client.xml</code> in the
            <code class="literal">external-customize</code> sample.</p><div class="section" title="9.2.6.1.&nbsp;The Service Endpoint Interface Class"><div class="titlepage"><div><div><h5 class="title" id="sei-class">9.2.6.1.&nbsp;The Service Endpoint Interface Class</h5></div></div></div><p><span class="command"><strong>wscompile</strong></span> will generate the service
                endpoint interface class <code class="literal">MathUtil</code> instead
                of the default <code class="literal">AddNumbersImpl</code> in this
                example:</p><div class="informalexample"><pre class="programlisting"><span class="Comment">&lt;!-- wsdl:portType customization --&gt;</span>
<span class="ReservedWord">&lt;bindings</span> <span class="Identifier">node</span>=<span class="String">"wsdl:definitions/wsdl:portType[@name='AddNumbersImpl']"</span><span class="ReservedWord">&gt;</span>
    <span class="Comment">&lt;!-- change the generated SEI class --&gt;</span>
    <span class="ReservedWord">&lt;class</span> <span class="Identifier">name</span>=<span class="String">"MathUtil"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;javadoc&gt;</span>Perform mathematical computations<span class="ReservedWord">&lt;/javadoc&gt;</span>
    <span class="ReservedWord">&lt;/class&gt;</span>
<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div></div><div class="section" title="9.2.6.2.&nbsp;The Exception Class"><div class="titlepage"><div><div><h5 class="title" id="exception-class">9.2.6.2.&nbsp;The Exception Class</h5></div></div></div><p><span class="command"><strong>wsimport</strong></span> will generate the
                <code class="literal">MathUtilException</code> class instead of the
                default <code class="literal">AddNumbersExeption</code> in this
                example:</p><div class="informalexample"><pre class="programlisting"><span class="Comment">&lt;!-- change the generated exception class name --&gt;</span>
<span class="ReservedWord">&lt;bindings</span>
        <span class="Identifier">node</span>=<span class="String">"wsdl:definitions/wsdl:portType[@name='AddNumbersImpl']/wsdl:operation[@name='addNumbers']/wsdl:fault[@name='AddNumbersException']"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;class</span> <span class="Identifier">name</span>=<span class="String">"MathUtilException"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;javadoc&gt;</span>Exception generated during computation<span class="ReservedWord">&lt;/javadoc&gt;</span>
    <span class="ReservedWord">&lt;/class&gt;</span>
<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div></div><div class="section" title="9.2.6.3.&nbsp;The Service Class"><div class="titlepage"><div><div><h5 class="title" id="service-class">9.2.6.3.&nbsp;The Service Class</h5></div></div></div><p><span class="command"><strong>wsimport</strong></span> will generate
                <code class="literal">MathUtilService</code> instead of the default
                <code class="literal">AddNumbersService</code> in this example:</p><div class="informalexample"><pre class="programlisting"><span class="Comment">&lt;!-- wsdl:service customization --&gt;</span>
<span class="ReservedWord">&lt;bindings</span> <span class="Identifier">node</span>=<span class="String">"wsdl:definitions/wsdl:service[@name='AddNumbersService']"</span><span class="ReservedWord">&gt;</span>
    <span class="Comment">&lt;!-- change the generated service class --&gt;</span>
    <span class="ReservedWord">&lt;class</span> <span class="Identifier">name</span>=<span class="String">"MathUtilService"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;javadoc&gt;</span>Service to perform mathematical computations<span class="ReservedWord">&lt;/javadoc&gt;</span>
    <span class="ReservedWord">&lt;/class&gt;</span>
<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div></div></div><div class="section" title="9.2.7.&nbsp;Java Method Customization"><div class="titlepage"><div><div><h4 class="title" id="java-method-customization">9.2.7.&nbsp;Java Method Customization</h4></div></div></div><p>The <code class="literal">jaxws:method</code> binding declaration is
            used to customize the generated Java method name of a service
            endpoint interface and to customize the port accessor method in
            the generated <code class="literal">Service</code> class. Refer to the
            external binding declaration file
            <code class="literal">custom-client.xml</code> in the
            <code class="literal">external-customize</code> sample.</p><div class="section" title="9.2.7.1.&nbsp;Service Endpoint Interface Methods"><div class="titlepage"><div><div><h5 class="title" id="sei-method">9.2.7.1.&nbsp;Service Endpoint Interface Methods</h5></div></div></div><p><span class="command"><strong>wsimport</strong></span> will generate a method named
                <code class="literal">add</code> instead of the default
                <code class="literal">addNumbers</code> in this example:</p><div class="informalexample"><pre class="programlisting"><span class="Comment">&lt;!-- wsdl:portType operation customization --&gt;</span>
<span class="ReservedWord">&lt;bindings</span>
        <span class="Identifier">node</span>=<span class="String">"wsdl:definitions/wsdl:portType[@name='AddNumbersImpl']/wsdl:operation[@name='addNumbers']"</span><span class="ReservedWord">&gt;</span>
    <span class="Comment">&lt;!-- change java method name from addNumbers() to add() --&gt;</span>
    <span class="ReservedWord">&lt;method</span> <span class="Identifier">name</span>=<span class="String">"add"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;javadoc&gt;</span>Adds the numbers<span class="ReservedWord">&lt;/javadoc&gt;</span>
    <span class="ReservedWord">&lt;/method&gt;</span>
<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div></div><div class="section" title="9.2.7.2.&nbsp;Port Accessor Methods in the Service Class"><div class="titlepage"><div><div><h5 class="title" id="port-accessor-method-in-service">9.2.7.2.&nbsp;Port Accessor Methods in the Service Class</h5></div></div></div><p><span class="command"><strong>wsimport</strong></span> will generate the
                <code class="literal">getMathUtil</code> port accessor method in the
                generated <code class="literal">Service</code> class instead of the
                default <code class="literal">getAddNumbersImplPort</code> method in
                this example:</p><div class="informalexample"><pre class="programlisting"><span class="Comment">&lt;!-- change the port accessor method --&gt;</span>
<span class="ReservedWord">&lt;bindings</span>
        <span class="Identifier">node</span>=<span class="String">"wsdl:definitions/wsdl:service[@name='AddNumbersService']/wsdl:port[@name='AddNumbersImplPort']"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;method</span> <span class="Identifier">name</span>=<span class="String">"getMathUtil"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;javadoc&gt;</span>Returns MathUtil port<span class="ReservedWord">&lt;/javadoc&gt;</span>
    <span class="ReservedWord">&lt;/method&gt;</span>
<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div></div></div><div class="section" title="9.2.8.&nbsp;Java Parameter Customization"><div class="titlepage"><div><div><h4 class="title" id="java-parameter-customization">9.2.8.&nbsp;Java Parameter Customization</h4></div></div></div><p>The <code class="literal">jaxws:parameter</code> binding declaration
            is used to change the parameter name of generated Java methods. It
            can be used to change the method parameter of a
            <code class="literal">wsdl:operation</code> in a
            <code class="literal">wsdl:portType.</code> Refer to the external binding
            declaration file <code class="literal">custom-client.xml</code> of the
            <code class="literal">external-customize</code> sample.</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;bindings</span>
        <span class="Identifier">node</span>=<span class="String">"wsdl:definitions/wsdl:portType[@name='AddNumbersImpl']/wsdl:operation[@name='addNumbers']"</span><span class="ReservedWord">&gt;</span>
    <span class="Comment">&lt;!-- rename method parameters--&gt;</span>
    <span class="ReservedWord">&lt;parameter</span>
            <span class="Identifier">part</span>=<span class="String">"definitions/message[@name='addNumbers']/part[@name='parameters']"</span>
            <span class="Identifier">element</span>=<span class="String">"tns:number1"</span> <span class="Identifier">name</span>=<span class="String">"num1"</span><span class="ReservedWord">/&gt;</span>
    
    ...
    
<span class="ReservedWord">&lt;/bindings&gt;</span></pre></div><p>The above sample renames the default parameter name of the
            Java method <code class="literal">addNumbers</code> from
            <code class="literal">number1</code> to <code class="literal">num1</code>.</p></div><div class="section" title="9.2.9.&nbsp;Javadoc customization"><div class="titlepage"><div><div><h4 class="title" id="javadoc-customization">9.2.9.&nbsp;Javadoc customization</h4></div></div></div><p><code class="literal">jaxws:javadoc</code> customization can be used
            to specify javadoc text for java package, class(SEI, Service or
            Exception class) and on the methods in SEI and service class.
            Inorder to do it,it should appear on the corresponding wsdl
            nodes.</p><p>For package level javadoc:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;jaxws:package</span> <span class="Identifier">name</span>=<span class="String">"xs:string"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;jaxws:javadoc&gt;</span>xs:string<span class="ReservedWord">&lt;/jaxws:javadoc&gt;</span>
<span class="ReservedWord">&lt;/jaxws:package&gt;</span></pre></div><p>For class level javadoc:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;jaxws:class</span> <span class="Identifier">name</span>=<span class="String">"xs:string"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;jaxws:javadoc&gt;</span>xs:string<span class="ReservedWord">&lt;/jaxws:javadoc&gt;</span>
<span class="ReservedWord">&lt;/jaxws:class&gt;</span></pre></div><p>For method level javadoc:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;jaxws:method</span> <span class="Identifier">name</span>=<span class="String">"xs:string"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;jaxws:javadoc&gt;</span>xs:string<span class="ReservedWord">&lt;/jaxws:javadoc&gt;</span>
<span class="ReservedWord">&lt;/jaxws:method&gt;</span> </pre></div><p>For specific samples on javadoc customization for class,
            refer <a class="xref" href="ch03.html#sei-class" title="9.2.6.1.&nbsp;The Service Endpoint Interface Class">The Service Endpoint Interface Class</a>, <a class="xref" href="ch03.html#exception-class" title="9.2.6.2.&nbsp;The Exception Class">The Exception Class</a> and <a class="xref" href="ch03.html#service-class" title="9.2.6.3.&nbsp;The Service Class">The Service Class</a> customization.
            For javadoc customization on method refer <a class="xref" href="ch03.html#sei-method" title="9.2.7.1.&nbsp;Service Endpoint Interface Methods">Service Endpoint Interface Methods</a> and <a class="xref" href="ch03.html#port-accessor-method-in-service" title="9.2.7.2.&nbsp;Port Accessor Methods in the Service Class">Port Accessor Methods in the Service Class</a> customization and for package level
            customization refer <a class="xref" href="ch03.html#package-customization" title="9.2.2.&nbsp;Package Customization">Package Customization</a>.</p></div><div class="section" title="9.2.10.&nbsp;XML Schema Customization"><div class="titlepage"><div><div><h4 class="title" id="xml-schema-customization">9.2.10.&nbsp;XML Schema Customization</h4></div></div></div><p>An XML schema inlined inside a compiled WSDL file can be
            customized by using standard JAXB bindings. These JAXB bindings
            can live inside the schema or as the child of a
            <code class="literal">jaxws:bindings</code> element in an external binding
            declaration file:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;jaxws:bindings</span>
        <span class="Identifier">node</span>=<span class="String">"wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='http://duke.example.org']"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;jaxb:schemaBindings&gt;</span>
        <span class="ReservedWord">&lt;jaxb:package</span> <span class="Identifier">name</span>=<span class="String">"fromwsdl.server"</span><span class="ReservedWord">/&gt;</span>
    <span class="ReservedWord">&lt;/jaxb:schemaBindings&gt;</span>
<span class="ReservedWord">&lt;/jaxws:bindings&gt;</span></pre></div><p>External XML schema files imported by the WSDL file can be
            customized using a JAXB external binding declaration file:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;jxb:bindings</span> <span class="Identifier">xmlns:xsd</span>=<span class="String">"http://www.w3.org/2001/XMLSchema"</span>
        <span class="Identifier">xmlns:jxb</span>=<span class="String">"http://java.sun.com/xml/ns/jaxb"</span> <span class="Identifier">version</span>=<span class="String">"1.0"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;jxb:bindings</span>
            <span class="Identifier">schemaLocation</span>=<span class="String">"http://localhost:8080/jaxws-external-customize/schema1.xsd"</span>
            <span class="Identifier">node</span>=<span class="String">"/xsd:schema"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;jxb:schemaBindings&gt;</span>
            <span class="ReservedWord">&lt;jxb:package</span> <span class="Identifier">name</span>=<span class="String">"fromjava.client"</span><span class="ReservedWord">/&gt;</span>
        <span class="ReservedWord">&lt;/jxb:schemaBindings&gt;</span>
    <span class="ReservedWord">&lt;/jxb:bindings&gt;</span>
    
    ...
    
<span class="ReservedWord">&lt;/jxb:bindings&gt;</span></pre></div><p>The external JAXB binding declaration file can be passed to
            <span class="command"><strong>wsimport</strong></span> using the <code class="option">-b</code> switch.
            See the JAX-WS <a class="xref" href="ch04.html#wscompiletool" title="1.2.&nbsp;wsimport"><span class="command"><strong>wsimport</strong></span></a> documentation for details.</p></div><div class="section" title="9.2.11.&nbsp;Handler Chain Customization"><div class="titlepage"><div><div><h4 class="title" id="handler-chain-customization">9.2.11.&nbsp;Handler Chain Customization</h4></div></div></div><p><code class="literal">jaxws:bindings</code> customization can be used
            to customize or add handlers. All that is needed is to inline a
            handler chain configuration conforming to JSR 181 Handler Chain
            configuration schema inside <code class="literal">jaxws:bindings</code>
            element.</p><p>Below is a sample JAX-WS binding declaration file with JSR
            181 handler chain configuration:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;jaxws:bindings</span> <span class="Identifier">xmlns:xsd</span>=<span class="String">"http://www.w3.org/2001/XMLSchema"</span>
        <span class="Identifier">xmlns:jaxb</span>=<span class="String">"http://java.sun.com/xml/ns/jaxb"</span>
        <span class="Identifier">xmlns:wsdl</span>=<span class="String">"http://schemas.xmlsoap.org/wsdl/"</span>
        <span class="Identifier">wsdlLocation</span>=<span class="String">"http://localhost:8080/jaxws-fromwsdlhandler/addnumbers?WSDL"</span>
        <span class="Identifier">xmlns:jaxws</span>=<span class="String">"http://java.sun.com/xml/ns/jaxws"</span>
        <span class="Identifier">xmlns:javaee</span>=<span class="String">"http://java.sun.com/xml/ns/javaee"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;jaxws:bindings</span> <span class="Identifier">node</span>=<span class="String">"wsdl:definitions"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;javaee:handler-chain&gt;</span>
            <span class="ReservedWord">&lt;javaee:handler-chain-name&gt;</span>LoggingHandlers
            <span class="ReservedWord">&lt;/javaee:handler-chain-name&gt;</span>
            
            <span class="ReservedWord">&lt;javaee:handler&gt;</span>
                <span class="ReservedWord">&lt;javaee:handler-name&gt;</span>Logger<span class="ReservedWord">&lt;/javaee:handler-name&gt;</span>
                <span class="ReservedWord">&lt;javaee:handler-class&gt;</span>fromwsdlhandler.common.LoggingHandler
                <span class="ReservedWord">&lt;/javaee:handler-class&gt;</span>
            <span class="ReservedWord">&lt;/javaee:handler&gt;</span>
        <span class="ReservedWord">&lt;/javaee:handler-chain&gt;</span>
    <span class="ReservedWord">&lt;/jaxws:bindings&gt;</span>
<span class="ReservedWord">&lt;/jaxws:bindings&gt;</span></pre></div><p>When this customization file is passed on to
            <span class="command"><strong>wsimport</strong></span> tool using -b switch together with the
            WSDL, <span class="command"><strong>wsimport</strong></span> generates all the artifacts
            togather with a handler configuration file which has everything
            inside <code class="literal">jaxws:bindings</code> element enclosing the
            <code class="literal">jws:handler-chain</code> element. It also add
            <code class="literal">@javax.jws.HandlerChain</code> annotation in the
            generated SEI class. JAXWS runtime uses the
            <code class="literal">@HandlerChain</code> annotation from the SEI to find
            the handlers that has to be added into the handle chain.</p></div></div></div><div lang="en" class="section" title="10.&nbsp;Annotations"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-annotations">10.&nbsp;Annotations</h2></div></div></div><div class="section" title="10.1.&nbsp;Overview"><div class="titlepage"><div><div><h3 class="title" id="section-031540603185018">10.1.&nbsp;Overview</h3></div></div></div><p>Annotations play a critical role in JAX-WS
        2.2. First, annotations are used in mapping
        Java to WSDL and schema. Second, annotations are used a runtime to
        control how the JAX-WS runtime processes and responds to web service
        invocations. Currently the annotations utilized by JAXR-WS 2.0 are
        defined in separate JSRs:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><a class="link" href="http://www.jcp.org/en/jsr/detail?id=181" target="_top">JSR 181:
                Web Services Metadata for the Java TM Platform</a></p></li><li class="listitem"><p><a class="link" href="http://www.jcp.org/en/jsr/detail?id=222" target="_top">JSR 222:
                Java TM Architecture for XML Binding (JAXB) 2.1</a></p></li><li class="listitem"><p><a class="link" href="http://www.jcp.org/en/jsr/detail?id=224" target="_top">JSR 224:
                Java TM API for XML Web Services (JAX-WS) 2.0 and
                2.1</a></p></li><li class="listitem"><p><a class="link" href="http://www.jcp.org/en/jsr/detail?id=250" target="_top">JSR 250:
                Common Annotations for the Java TM Platform</a>.</p></li></ul></div></div><div class="section" title="10.2.&nbsp;JSR 181 (Web Services Metadata) Annotations"><div class="titlepage"><div><div><h3 class="title" id="jsr-181">10.2.&nbsp;JSR 181 (Web Services Metadata) Annotations</h3></div></div></div><p>Because JSR 181 has been written to work with JAX-RPC 1.1, we
        have made slight changes in the use and interpretation of these
        annotations to work better with JAX-WS 2.0. We are working with the
        JSR 181 expert group to align the next release with JAX-WS 2.0 and we
        hope that all of the changes we have made will be folded in.</p><div class="section" title="10.2.1.&nbsp;@javax.jws.WebService"><div class="titlepage"><div><div><h4 class="title" id="javax-jws-webservice-outline">10.2.1.&nbsp;<code class="literal">@javax.jws.WebService</code></h4></div></div></div><p>The purpose of this annotation is to mark an endpoint
            implementation as implementing a web service or to mark that a
            service endpoint interface as defining a web service interface.
            All endpoint implementation classes MUST have a
            <code class="literal">WebService</code> annotation and must meet the
            requirements of section 3.3 of the <a class="link" href="http://www.jcp.org/en/jsr/detail?id=224" target="_top">JAX-WS
            2.0</a> specification.</p><div class="table"><a name="d0e4117"></a><p class="title"><b>Table&nbsp;3.&nbsp;<code class="literal">@javax.jws.WebService</code> - Description
                of Properties</b></p><div class="table-contents"><table summary="@javax.jws.WebService - Description&#xA;                of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">name</code></p></td><td><p>The name of the
                            <code class="literal">wsdl:portType</code></p></td><td><p>The unqualified name of the Java class
                            or interface</p></td></tr><tr><td><p><code class="literal">targetNamespace</code></p></td><td><p>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.</p></td><td><p>The namespace mapped from the package
                            name containing the web service according to section
                            3.2 of the <a class="link" href="http://www.jcp.org/en/jsr/detail?id=224" target="_top">JAX-WS
                            2.0</a> specification.</p></td></tr><tr><td><p><code class="literal">serviceName</code></p></td><td><p>The Service name of the web service:
                            <code class="literal">wsdl:service</code></p></td><td><p>The unqualified name of the Java class
                            or interface + "Service"</p></td></tr><tr><td><p><code class="literal">endpointInterface</code></p></td><td><p>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
                            <code class="literal">@WebService</code> and
                            <code class="literal">@HandlerChain</code> In addition, the
                            <code class="literal">@WebService</code> annotation MUST NOT
                            include the name annotation element. The endpoint
                            implementation class is not required to implement
                            the endpointInterface.</p></td><td><p>None &#8211; 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.</p></td></tr><tr><td><p><code class="literal">portName</code></p></td><td><p>The
                            <code class="literal">wsdl:portName</code></p></td><td><p>The <code class="literal">WebService.name</code>
                            + "Port"</p></td></tr><tr><td><p><code class="literal">wsdlLocation</code></p></td><td><p>Not currently used by
                            JAX-WS RI 2.2.7</p></td><td><p></p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.2.1.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-5790511949612727">10.2.1.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Retention(value = RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target({ElementType.TYPE})</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> WebService {
    String name() <span class="ReservedWord">default</span> <span class="String">""</span>;

    String targetNamespace() <span class="ReservedWord">default</span> <span class="String">""</span>;

    String serviceName() <span class="ReservedWord">default</span> <span class="String">""</span>;

    String wsdlLocation() <span class="ReservedWord">default</span> <span class="String">""</span>;

    String endpointInterface() <span class="ReservedWord">default</span> <span class="String">""</span>;

    String portName() <span class="ReservedWord">default</span> <span class="String">""</span>;
}</pre></div></div><div class="section" title="10.2.1.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-724263520121821">10.2.1.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e4230"></a><p class="title"><b>Example&nbsp;3.&nbsp;<code class="literal">@javax.jws.WebService</code> - Example
                    1</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebService(name = "AddNumbers",
        targetNamespace = "http://duke.example.org")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl {
    <span class="Comment">/**
     * @param number1
     * @param number2
     * @return The sum
     * @throws AddNumbersException if any of the numbers to be added is
     *                             negative.
     */</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            AddNumbersException {
        <span class="ReservedWord">if</span> (number1 &lt; <span class="Numeric">0</span> || number2 &lt; <span class="Numeric">0</span>) {
            <span class="ReservedWord">throw</span> <span class="ReservedWord">new</span> AddNumbersException(<span class="String">"Negative number cant be added "</span> +
                    <span class="String">"!"</span>, <span class="String">"Numbers: "</span> + number1 + <span class="String">", "</span> + number2);
        }
        <span class="ReservedWord">return</span> number1 + number2;
    }
}</pre></div></div><br class="example-break"><p>If you are familiar with JAX-RPC 1.1, you will notice
                that the <code class="literal">AddNumbersImpl</code> implementation
                class does not implement a service endpoint interface. In
                JAX-WS 2.2 a service endpoint
                interface is no longer required. If a service endpoint
                interfaces is desired, then the <code class="literal">@WebService</code>
                annotation on the endpoint implementation is modified to
                specify the endpoint interface and the actual service endpoint
                interface must also have a <code class="literal">@WebService</code>
                annotation. The following is the above
                <code class="literal">AddNumbersImpl</code> modified to use a service
                endpoint interface.</p><div class="example"><a name="d0e4251"></a><p class="title"><b>Example&nbsp;4.&nbsp;<code class="literal">@javax.jws.WebService</code> - Example
                    2 - Implementation class using Service Endpoint
                    Interface</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebService(endpointInterface = "annotations.server.AddNumbersIF")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl {
    <span class="Comment">/**
     * @param number1
     * @param number2
     * @return The sum
     * @throws AddNumbersException if any of the numbers to be added is 
     * negative.
     */</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            AddNumbersException {
        <span class="ReservedWord">if</span> (number1 &lt; <span class="Numeric">0</span> || number2 &lt; <span class="Numeric">0</span>) {
            <span class="ReservedWord">throw</span> <span class="ReservedWord">new</span> AddNumbersException(<span class="String">"Negative number cant be "</span> +
                    <span class="String">"added!"</span>, <span class="String">"Numbers: "</span> + number1 + <span class="String">", "</span> + number2);
        } <span class="ReservedWord">return</span> number1 + number2;
    }
}</pre><pre class="programlisting"><span class="Annotation">@WebService(targetNamespace = "http://duke.example.org",
        name = "AddNumbers")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">interface</span> AddNumbersIF <span class="ReservedWord">extends</span> Remote {

    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            RemoteException, AddNumbersException;

}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.2.2.&nbsp;@javax.jws.WebMethod"><div class="titlepage"><div><div><h4 class="title" id="javax-jws-webmethod-outline">10.2.2.&nbsp;<code class="literal">@javax.jws.WebMethod</code></h4></div></div></div><p>The purpose of this annotation is to expose a method as a
            web service operation. The method must meet all the requirements
            of section 3.4 of the <a class="link" href="http://www.jcp.org/en/jsr/detail?id=224" target="_top">JAX-WS
            2.0</a> specification.</p><div class="table"><a name="d0e4269"></a><p class="title"><b>Table&nbsp;4.&nbsp;<code class="literal">@javax.jws.WebMethod</code> - Description
                of Properties</b></p><div class="table-contents"><table summary="@javax.jws.WebMethod - Description&#xA;                of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">operationName</code></p></td><td><p>The name of the
                            <code class="literal">wsdl:operation</code> matching this
                            method. For operations using the mode defined by
                            <code class="literal">SOAPBinding.Style.DOCUMENT</code>,
                            <code class="literal">SOAPBinding.Use.LITERAL</code>, and
                            <code class="literal">SOAPBinding.ParameterStyle.BARE</code>,
                            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
                            <code class="literal">@WebService.targetNamespace</code> or
                            its default value.</p></td><td><p>The name of the Java
                            method</p></td></tr><tr><td><p><code class="literal">action</code></p></td><td><p>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.</p></td><td><p>""</p></td></tr><tr><td><p><code class="literal">exclude</code></p></td><td><p>Used to exclude a method from the
                            WebService.</p></td><td><p>false</p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.2.2.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-54961496738835">10.2.2.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Retention(value = RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target({ElementType.METHOD})</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> WebMethod {
    String operationName() <span class="ReservedWord">default</span> <span class="String">""</span>;

    String action() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="ReservedWord">boolean</span> exclude() <span class="ReservedWord">default</span> false;
}</pre></div></div><div class="section" title="10.2.2.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-998755081708335">10.2.2.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e4344"></a><p class="title"><b>Example&nbsp;5.&nbsp;<code class="literal">@javax.jws.WebMethod</code> -
                    Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebService(targetNamespace = "http://duke.example.org",
        name = "AddNumbers")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">interface</span> AddNumbersIF <span class="ReservedWord">extends</span> Remote {

    <span class="Annotation">@WebMethod(operationName = "add", action = "urn:addNumbers")</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            RemoteException, AddNumbersException;

}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.2.3.&nbsp;@javax.jws.OneWay"><div class="titlepage"><div><div><h4 class="title" id="javax-jws-oneway-outline">10.2.3.&nbsp;<code class="literal">@javax.jws.OneWay</code></h4></div></div></div><p>The purpose of this annotation is to mark a method as a web
            service one-way operation. The method must meet all the
            requirements of section 3.4.1 of the <a class="link" href="http://www.jcp.org/en/jsr/detail?id=224" target="_top">JSR
            224</a> spec.</p><p>There are no properties on the <code class="literal">OneWay</code>
            annotation.</p><div class="section" title="10.2.3.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-57285842212862">10.2.3.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Retention(value = RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target({ElementType.METHOD})</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> Oneway {
}</pre></div></div><div class="section" title="10.2.3.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-877748055333987">10.2.3.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e4374"></a><p class="title"><b>Example&nbsp;6.&nbsp;<code class="literal">@javax.jws.OneWay</code> -
                    Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebService(name = "CheckIn")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> CheckInIF {
    
    <span class="Annotation">@WebMethod</span>
    <span class="Annotation">@OneWay</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> checkIn(String name);

}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.2.4.&nbsp;@javax.jws.WebParam"><div class="titlepage"><div><div><h4 class="title" id="javax-jws-webparam-outline">10.2.4.&nbsp;<code class="literal">@javax.jws.WebParam</code></h4></div></div></div><p>This annotation is used to customize the mapping of a single
            parameter to a message part or element.</p><div class="table"><a name="d0e4387"></a><p class="title"><b>Table&nbsp;5.&nbsp;<code class="literal">@javax.jws.WebParam</code> - Description of
                Properties</b></p><div class="table-contents"><table summary="@javax.jws.WebParam - Description of&#xA;                Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">name</code></p></td><td><p>Name of the parameter.</p><p>If
                            the operation is RPC style and
                            <code class="literal">@WebParam.partName</code> has not been
                            specified, this is name of the
                            <code class="literal">wsdl:part</code> representing the
                            parameter.</p><p><code class="literal">@WebMethod.operation</code>
                            Name, if the operation is document style and the
                            parameter style is
                            <code class="literal">BARE</code>.</p><p>Otherwise, the
                            default is <code class="literal">argN</code> 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.</p><p>A name MUST
                            be specified if the operation is document style, the
                            parameter style is <code class="literal">BARE</code>, and the
                            mode is <code class="literal">OUT</code> or
                            <code class="literal">INOUT</code>.</p></td><td><p><code class="literal">@WebMethod.operation</code>
                            Name, if the operation is document style and the
                            parameter style is <code class="literal">BARE</code>.
                            Otherwise, the default is <code class="literal">argN</code>,
                            where <code class="literal">N</code> represents the index of
                            the parameter in the method signature (starting at
                            <code class="literal">arg0</code>).</p></td></tr><tr><td><p><code class="literal">targetNamespace</code></p></td><td><p>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.</p></td><td><p>The empty namespace, if the operation
                            is document style, the parameter style is
                            <code class="literal">WRAPPED</code>, and the parameter does
                            not map to a header. Otherwise, the default is the
                            <code class="literal">targetNamespace</code> for the Web
                            Service.</p></td></tr><tr><td><p><code class="literal">mode</code></p></td><td><p>Represents the direction the parameter
                            flows for this method. Possible values are
                            <code class="literal">IN</code>, <code class="literal">INOUT</code> and
                            <code class="literal">OUT</code>. <code class="literal">INOUT</code> and
                            <code class="literal">OUT</code> modes can only be used with
                            parameters that meet the requirements for a holder
                            as classified by section 3.5 of the <a class="link" href="http://www.jcp.org/en/jsr/detail?id=224" target="_top">JAX-WS
                            2.0</a> specification. <code class="literal">OUT</code> and
                            <code class="literal">INOUT</code> parameters can be used by
                            all <code class="literal">RPC</code> and
                            <code class="literal">DOCUMENT</code> bindings.</p></td><td><p><code class="literal">IN</code> for non-holder
                            parameters <code class="literal">INOUT</code> for holder
                            parameters.</p></td></tr><tr><td><p><code class="literal">header</code></p></td><td><p>Specifies whether the parameter should
                            be carried in a header.</p></td><td><p><code class="literal">FALSE</code></p></td></tr><tr><td><p><code class="literal">partName</code></p></td><td><p>Used to specify the
                            <code class="literal">partName</code> for the parameter with
                            <code class="literal">RPC</code> or
                            <code class="literal">DOCUMENT</code>/<code class="literal">BARE</code>
                            operations.</p></td><td><p><code class="literal">@WebParam.name
                            </code></p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.2.4.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-704139125883689">10.2.4.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Retention(value = RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target({ElementType.PARAMETER})</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> WebParam {

    <span class="ReservedWord">public</span> enum Mode {
        IN,
        OUT,
        INOUT
    }

    String name() <span class="ReservedWord">default</span> <span class="String">""</span>;

    String targetNamespace() <span class="ReservedWord">default</span> <span class="String">""</span>;

    Mode mode() <span class="ReservedWord">default</span> Mode.IN;

    <span class="ReservedWord">boolean</span> header() <span class="ReservedWord">default</span> false;

    String partName() <span class="ReservedWord">default</span> <span class="String">""</span>;
}</pre></div></div><div class="section" title="10.2.4.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-759744573502372">10.2.4.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e4569"></a><p class="title"><b>Example&nbsp;7.&nbsp;<code class="literal">@javax.jws.WebParam</code> - Example
                    1</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebService(targetNamespace = "http://duke.example.org",
        name = "AddNumbers")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">interface</span> AddNumbersIF <span class="ReservedWord">extends</span> Remote {
 
    <span class="Annotation">@WebMethod(operationName = "add", action = "urn:addNumbers")</span>
    <span class="Annotation">@WebResult(name = "return")</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="Annotation">@WebParam(name = "num1")</span> <span class="ReservedWord">int</span> number1, 
                          <span class="Annotation">@WebParam(name = "num2")</span> <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            RemoteException, AddNumbersException;

}</pre></div></div><br class="example-break"><div class="example"><a name="d0e4576"></a><p class="title"><b>Example&nbsp;8.&nbsp;<code class="literal">@javax.jws.WebParam</code> - Example
                    2</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebService(targetNamespace = "http://duke.example.org",
        name = "AddNumbers")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">interface</span> AddNumbersIF <span class="ReservedWord">extends</span> Remote {

    <span class="Annotation">@WebMethod(operationName = "add", action = "urn:addNumbers")</span>
    <span class="Annotation">@WebResult(name = "return")</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> addNumbers(<span class="Annotation">@WebParam(name = "num1")</span> <span class="ReservedWord">int</span> number1, 
                           <span class="Annotation">@WebParam(name = "num2")</span> <span class="ReservedWord">int</span> number2, 
                           <span class="Annotation">@WebParam(name = "result",
            mode = WebParam.Mode.OUT)</span> Holder&lt;Integer&gt; result) <span class="ReservedWord">throws</span> RemoteException, AddNumbersException;


}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.2.5.&nbsp;@javax.jws.WebResult"><div class="titlepage"><div><div><h4 class="title" id="javax-jws-webresult-outline">10.2.5.&nbsp;<code class="literal">@javax.jws.WebResult</code></h4></div></div></div><p>This annotation is used to customize the mapping of the
            method return value to a WSDL part or XML element.</p><div class="table"><a name="d0e4589"></a><p class="title"><b>Table&nbsp;6.&nbsp;<code class="literal">@javax.jws.WebResult</code> - Description
                of Properties</b></p><div class="table-contents"><table summary="@javax.jws.WebResult - Description&#xA;                of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">name</code></p></td><td><p>The name of the return value in the
                            WSDL and on the wire. For <code class="literal">RPC</code>
                            bindings this is the part name of the return value
                            in the response message. For
                            <code class="literal">DOCUMENT</code> bindings this is the
                            local name of the XML element representing the
                            return value.</p></td><td><p>"return" for <code class="literal">RPC</code> and
                            <code class="literal">DOCUMENT</code>/<code class="literal">WRAPPED</code>
                            bindings. Method name + "Response" for
                            <code class="literal">DOCUMENT</code>/<code class="literal">BARE</code>
                            bindings.</p></td></tr><tr><td><p><code class="literal">targetNamespace</code></p></td><td><p>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.</p></td><td><p>The empty namespace, if the operation
                            is document style, the parameter style is
                            <code class="literal">WRAPPED</code>, and the return value
                            does not map to a header, Otherwise, the default is
                            the <code class="literal">targetNamespace</code> for the Web
                            Service.</p></td></tr><tr><td><p><code class="literal">header</code></p></td><td><p>Specifies whether the result should be
                            carried in a header.</p></td><td><p><code class="literal">FALSE</code></p></td></tr><tr><td><p><code class="literal">partName</code></p></td><td><p>Used to specify the
                            <code class="literal">partName</code> for the result with
                            <code class="literal">RPC</code> or
                            <code class="literal">DOCUMENT</code>/<code class="literal">BARE</code>
                            operations.</p></td><td><p><code class="literal">@WebResult.name
                            </code></p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.2.5.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-825230071110141">10.2.5.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Retention(value = RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target({ElementType.METHOD})</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> WebResult {

    String name() <span class="ReservedWord">default</span> <span class="String">"return"</span>;

    String targetNamespace() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="ReservedWord">boolean</span> header() <span class="ReservedWord">default</span> false;

    String partName() <span class="ReservedWord">default</span> <span class="String">""</span>;
}</pre></div></div><div class="section" title="10.2.5.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-324659921484612">10.2.5.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e4701"></a><p class="title"><b>Example&nbsp;9.&nbsp;<code class="literal">@javax.jws.WebResult</code> -
                    Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebService(targetNamespace = "http://duke.example.org",
        name = "AddNumbers")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">interface</span> AddNumbersIF <span class="ReservedWord">extends</span> Remote {
 
    <span class="Annotation">@WebMethod(operationName = "add", action = "urn:addNumbers")</span>
    <span class="Annotation">@WebResult(name = "return")</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="Annotation">@WebParam(name = "num1")</span> <span class="ReservedWord">int</span> number1, 
                          <span class="Annotation">@WebParam(name = "num2")</span> <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            RemoteException, AddNumbersException;

}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.2.6.&nbsp;@javax.jws.HandlerChain"><div class="titlepage"><div><div><h4 class="title" id="javax-jws-handlerchain-outline">10.2.6.&nbsp;<code class="literal">@javax.jws.HandlerChain</code></h4></div></div></div><p>This annotation is used to specified an externally defined
            handler chain.</p><div class="table"><a name="d0e4714"></a><p class="title"><b>Table&nbsp;7.&nbsp;<code class="literal">@javax.jws.HandlerChain</code> -
                Description of Properties</b></p><div class="table-contents"><table summary="@javax.jws.HandlerChain -&#xA;                Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">file</code></p></td><td><p>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.</p></td><td><p>None</p></td></tr><tr><td><p><code class="literal">name</code></p></td><td><p><span class="bold"><strong>DEPRECATED</strong></span> The handler chain
                            name from within the handler chain
                            file.</p></td><td><p>""</p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.2.6.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-888738992154297">10.2.6.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Retention(value = RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target({ElementType.TYPE})</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> HandlerChain {
    
    String file();

    <span class="Annotation">@Deprecated</span> String name() <span class="ReservedWord">default</span> <span class="String">""</span>;

}</pre></div></div><div class="section" title="10.2.6.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-0070675424428255">10.2.6.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e4765"></a><p class="title"><b>Example&nbsp;10.&nbsp;<code class="literal">@javax.jws.HandlerChain</code> -
                    Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebService</span>
<span class="Annotation">@HandlerChain(file = "handlers.xml")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl {
    <span class="Comment">/**
     * @param number1
     * @param number2
     * @return The sum
     * @throws AddNumbersException if any of the numbers to be added is
     *                             negative.
     */</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            AddNumbersException {
        <span class="ReservedWord">if</span> (number1 &lt; <span class="Numeric">0</span> || number2 &lt; <span class="Numeric">0</span>) {
            <span class="ReservedWord">throw</span> <span class="ReservedWord">new</span> AddNumbersException(<span class="String">"Negative number cant be added "</span> +
                    <span class="String">"!"</span>, <span class="String">"Numbers: "</span> + number1 + <span class="String">", "</span> + number2);
        }
        <span class="ReservedWord">return</span> number1 + number2;
    }

}</pre></div></div><br class="example-break"><div class="example"><a name="d0e4772"></a><p class="title"><b>Example&nbsp;11.&nbsp;<code class="literal">@javax.jws.HandlerChain</code> -
                    Example - handlers.xml</b></p><div class="example-contents"><pre class="programlisting"><span class="ReservedWord">&lt;jws:handler-config</span> <span class="Identifier">xmlns:jws</span>=<span class="String">"http://java.sun.com/xml/ns/javaee"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;jws:handler-chains&gt;</span>
        <span class="ReservedWord">&lt;jws:handler-chain&gt;</span>
            <span class="ReservedWord">&lt;jws:handler&gt;</span>
                <span class="ReservedWord">&lt;jws:handler-class&gt;</span>fromjavahandler.common.LoggingHandler
                <span class="ReservedWord">&lt;/jws:handler-class&gt;</span>
            <span class="ReservedWord">&lt;/jws:handler&gt;</span>
        <span class="ReservedWord">&lt;/jws:handler-chain&gt;</span>
    <span class="ReservedWord">&lt;/jws:handler-chains&gt;</span>
<span class="ReservedWord">&lt;/jws:handler-config&gt;</span></pre></div></div><br class="example-break"><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>When using a handler chain file, it is important
                    that the file is store in the appropriate place in the
                    classpath so that the file can be found. This means that
                    when a raw WAR file is created that the file must be place
                    in the proper directory. Please refer to the
                    <span class="application">fromjavahandlers</span> <a class="link" href="../samples/docs/jax-ws-ri-overview" target="_top">sample
                    application</a> and the <a class="xref" href="ch03.html#users-guide-handler" title="6.&nbsp;Handler">Handler</a>
                    for more information.</p></div></div></div><div class="section" title="10.2.7.&nbsp;@javax.jws.soap.SOAPBinding"><div class="titlepage"><div><div><h4 class="title" id="javax-jws-soap-soapbinding-outline">10.2.7.&nbsp;<code class="literal">@javax.jws.soap.SOAPBinding</code></h4></div></div></div><p>JSR 181 also allows you to specify a
            <code class="literal">SOAPBinding</code> annotation on an endpoint
            implementation or service endpoint interface. This annotation lets
            the developer choose between <code class="literal">DOCUMENT\LITERAL
            WRAPPED</code>, <code class="literal">DOCUMENT\LITERAL BARE</code>,
            <code class="literal">RPC\LITERAL</code> and <code class="literal">RPC\ENCODED</code>
            endpoints with the default being <code class="literal">DOCUMENT\LITERAL
            WRAPPED</code>. JAX-WS 2.2 does not
            support <code class="literal">RPC\ENCODED</code>. The main difference
            between <code class="literal">DOCUMENT\LITERAL BARE</code> and
            <code class="literal">DOCUMENT\LITERAL WRAPPED</code> is that methods on a
            <code class="literal">DOCUMENT\LITERAL WRAPPED</code> endpoint can have
            multiple parameters bound to the body of a SOAP message, while a
            <code class="literal">DOCUMENT\LITERAL BARE</code> can only have one such
            parameter. The main difference between <code class="literal">DOCUMENT\LITERAL
            WRAPPED</code> and <code class="literal">RPC\LITERAL</code> is that a
            <code class="literal">DOCUMENT\LITERAL</code> invocation can be fully
            validated by a standard validating XML parser, while an
            <code class="literal">RPC\LITERAL</code> invocation cannot because of the
            implied wrapper element around the invocation body.</p><div class="table"><a name="d0e4841"></a><p class="title"><b>Table&nbsp;8.&nbsp;<code class="literal">@javax.jws.soap.SOAPBinding</code> -
                Description of Properties</b></p><div class="table-contents"><table summary="@javax.jws.soap.SOAPBinding -&#xA;                Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">style</code></p></td><td><p>Defines the style for messages used in
                            a web service. The value can be either
                            <code class="literal">DOCUMENT</code> or
                            <code class="literal">RPC</code>.</p></td><td><p><code class="literal">DOCUMENT</code></p></td></tr><tr><td><p><code class="literal">use</code></p></td><td><p>Defines the encoding used for messages
                            used in web service. Can only be
                            <code class="literal">LITERAL</code> for JAX-WS
                            2.2.</p></td><td><p><code class="literal">LITERAL</code></p></td></tr><tr><td><p><code class="literal">parameterStyle</code></p></td><td><p>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 <code class="literal">WRAPPED</code>
                            or <code class="literal">BARE</code>. <code class="literal">BARE</code>
                            can only be used with <code class="literal">DOCUMENT</code>
                            style bindings.</p></td><td><p><code class="literal">WRAPPED</code></p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.2.7.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-980481850012988">10.2.7.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Retention(value = RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target({ElementType.TYPE, ElementType.METHOD})</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> SOAPBinding {
    
    <span class="ReservedWord">public</span> enum Style {
        DOCUMENT,
        RPC,
    }

    <span class="ReservedWord">public</span> enum Use {
        LITERAL,
        ENCODED,
    }

    <span class="ReservedWord">public</span> enum ParameterStyle {
        BARE,
        WRAPPED,
    }

    Style style() <span class="ReservedWord">default</span> Style.DOCUMENT;

    Use use() <span class="ReservedWord">default</span> Use.LITERAL;

    ParameterStyle parameterStyle() <span class="ReservedWord">default</span> ParameterStyle.WRAPPED;

}</pre></div></div><div class="section" title="10.2.7.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-106596084465574">10.2.7.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e4925"></a><p class="title"><b>Example&nbsp;12.&nbsp;<code class="literal">@javax.jws.soap.SOAPBinding</code> -
                    Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebService(targetNamespace = "http://duke.example.org",
        name = "AddNumbers")</span>
<span class="Annotation">@SOAPBinding(style = SOAPBinding.Style.RPC,
        use = SOAPBinding.Use.LITERAL)</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">interface</span> AddNumbersIF <span class="ReservedWord">extends</span> Remote {
 
    <span class="Annotation">@WebMethod(operationName = "add", action = "urn:addNumbers")</span>
    <span class="Annotation">@WebResult(name = "return")</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="Annotation">@WebParam(name = "num1")</span> <span class="ReservedWord">int</span> number1, 
                          <span class="Annotation">@WebParam(name = "num2")</span> <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            RemoteException, AddNumbersException;

}</pre></div></div><br class="example-break"></div></div></div><div class="section" title="10.3.&nbsp;JSR 224 (JAX-WS) Annotations"><div class="titlepage"><div><div><h3 class="title" id="jsr-224-jax-ws-annotations-outline">10.3.&nbsp;JSR 224 (JAX-WS) Annotations</h3></div></div></div><p>The following are standard annotations needed by JAX-WS that are
        not defined in JSR 181. The developer may not ever use these
        annotations directly as some of them are generated by JAX-WS tools but
        they will be presented here to avoid confusion.</p><div class="section" title="10.3.1.&nbsp;@javax.xml.ws.BindingType"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-ws-bindingtype-outline">10.3.1.&nbsp;<code class="literal">@javax.xml.ws.BindingType</code></h4></div></div></div><p>The <code class="literal">BindingType</code> annotation is used to
            specify the binding to use for a web service endpoint
            implementation class. As well as specify additional features that
            may be enabled.</p><p>This annotation may be overriden programmatically or via
            deployment descriptors, depending on the platform in use.</p><div class="table"><a name="d0e4948"></a><p class="title"><b>Table&nbsp;9.&nbsp;<code class="literal">@javax.xml.ws.BindingType</code> -
                Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.ws.BindingType -&#xA;                Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">value</code></p></td><td><p>A binding identifier (a
                            URI).</p><p>See the
                            <code class="literal">SOAPBinding</code> and
                            <code class="literal">HTTPBinding</code> for the definition of
                            the standard binding
                            identifiers.</p><p><code class="code">@see
                            javax.xml.ws.Binding</code></p><p><code class="code">@see
                            javax.xml.ws.soap.SOAPBinding#SOAP11HTTP_BINDING</code></p><p><code class="code">@see
                            javax.xml.ws.soap.SOAPBinding#SOAP12HTTP_BINDING</code></p><p><code class="code">@see
                            javax.xml.ws.http.HTTPBinding#HTTP_BINDING</code></p></td><td><p>"<code class="literal">SOAP 1.1
                            Protocol</code>"/<code class="literal">HTTP</code></p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.3.1.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-2239237830275984">10.3.1.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Target(ElementType.TYPE)</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Documented</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> BindingType {
    <span class="Comment">/**
     * A binding identifier (a URI).
     * If not specified, the default is the SOAP 1.1 / HTTP
     * binding.
     * &lt;p/&gt;
     * See the
     * SOAPBinding and
     * HTTPBinding
     * for the definition of the standard binding identifiers.
     *
     * @see javax.xml.ws.Binding
     * @see javax.xml.ws.soap.SOAPBinding#SOAP11HTTP_BINDING
     * @see javax.xml.ws.soap.SOAPBinding#SOAP12HTTP_BINDING
     * @see javax.xml.ws.http.HTTPBinding#HTTP_BINDING
     */</span>
    String value() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * An array of Features to enable/disable on the specified
     * binding.
     * If not specified, features will be enabled/disabled based
     * on their own rules. Refer to the documentation of the
     * feature
     * to determine when it will be automatically enabled.
     * &lt;p/&gt;
     * See the
     * SOAPBinding
     * for the definition of the standard feature identifiers.
     *
     * @see javax.xml.ws.RespectBindingFeature
     * @see javax.xml.ws.soap.AddressingFeature
     * @see javax.xml.ws.soap.MTOMFeature
     * @since JAX-WS 2.1
     */</span>
    Feature[] features() <span class="ReservedWord">default</span> {};
}</pre></div></div><div class="section" title="10.3.1.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-673452285502762">10.3.1.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e5011"></a><p class="title"><b>Example&nbsp;13.&nbsp;<code class="literal">@javax.xml.ws.BindingType</code> -
                    Example</b></p><div class="example-contents"><p>Given the web service defined by</p><pre class="programlisting"><span class="Annotation">@WebService</span>
<span class="Annotation">@BindingType(value = "http://www.w3.org/2003/05/soap/bindings/HTTP/")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl {
    <span class="Comment">/**
     * @param number1
     * @param number2
     * @return The sum
     * @throws AddNumbersException if any of the numbers to be added is
     *                             negative.
     */</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            AddNumbersException {
        <span class="ReservedWord">if</span> (number1 &lt; <span class="Numeric">0</span> || number2 &lt; <span class="Numeric">0</span>) {
            <span class="ReservedWord">throw</span> <span class="ReservedWord">new</span> AddNumbersException(<span class="String">"Negative number cant be "</span> + 
                    <span class="String">"added!"</span>, <span class="String">"Numbers: "</span> + number1 +
                    <span class="String">", "</span> + number2);
        }
        <span class="ReservedWord">return</span> number1 + number2;
    }
}</pre><p>The deployed endpoint would use the SOAP 1.2 over
                    HTTP binding.</p></div></div><br class="example-break"></div></div><div class="section" title="10.3.2.&nbsp;@javax.xml.ws.RequestWrapper"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-ws-requestwrapper-outline">10.3.2.&nbsp;<code class="literal">@javax.xml.ws.RequestWrapper</code></h4></div></div></div><p>This annotation annotates methods in the Service Endpoint
            Interface with the request wrapper bean to be used at
            runtime.</p><p>When starting from Java this annotation is used to resolve
            overloading conflicts in <code class="literal">DOCUMENT\LITERAL</code> mode.
            Only the <code class="literal">className</code> is required in this
            case.</p><div class="table"><a name="d0e5036"></a><p class="title"><b>Table&nbsp;10.&nbsp;<code class="literal">@javax.xml.ws.RequestWrapper</code> -
                Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.ws.RequestWrapper -&#xA;                Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">localName</code></p></td><td><p>Specifies the
                            <code class="literal">localName</code> of the XML Schema
                            element representing this request
                            wrapper.</p></td><td><p><code class="literal">operationName</code> as
                            defined by
                            <code class="literal">@javax.jws.WebMethod</code></p></td></tr><tr><td><p><code class="literal">targetNamespace</code></p></td><td><p>namespace of the request wrapper
                            element.</p></td><td><p>the <code class="literal">targetNamespace</code>
                            of the SEI</p></td></tr><tr><td><p><code class="literal">className</code></p></td><td><p>The name of the Class representing the
                            request wrapper.</p></td><td><p></p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.3.2.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-253709758478671">10.3.2.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Target({ElementType.TYPE, ElementType.METHOD})</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> RequestWrapper {
    <span class="Comment">/**
     * Elements local name.
     */</span>
    <span class="ReservedWord">public</span> String localName() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * Elements namespace name.
     */</span>
    <span class="ReservedWord">public</span> String targetNamespace() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * Request wrapper bean name.
     */</span>
    <span class="ReservedWord">public</span> String className() <span class="ReservedWord">default</span> <span class="String">""</span>;
}</pre></div></div><div class="section" title="10.3.2.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-677521323678242">10.3.2.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e5105"></a><p class="title"><b>Example&nbsp;14.&nbsp;<code class="literal">@javax.xml.ws.RequestWrapper</code> -
                    Example</b></p><div class="example-contents"><pre class="programlisting"><span class="ReservedWord">public</span> <span class="ReservedWord">interface</span> AddNumbersImpl {
    <span class="Comment">/**
     * @param arg1
     * @param arg0
     * @return returns int
     * @throws AddNumbersException_Exception
     */</span>
    <span class="Annotation">@WebMethod</span>
    <span class="Annotation">@WebResult(targetNamespace = "")</span>
    <span class="Annotation">@RequestWrapper(localName = "addNumbers", 
            targetNamespace = "http://server.fromjava/", 
            className = "fromjava.client.AddNumbers")</span>
    <span class="Annotation">@ResponseWrapper(localName = "addNumbersResponse",
            targetNamespace = "http://server.fromjava/", 
            className = "fromjava.client.AddNumbersResponse")</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="Annotation">@WebParam(name = "arg0", targetNamespace = "")</span> 
                              <span class="ReservedWord">int</span> arg0, <span class="Annotation">@WebParam(name = "arg1", targetNamespace = "")</span> <span class="ReservedWord">int</span> arg1) <span class="ReservedWord">throws</span> AddNumbersException_Exception;
}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.3.3.&nbsp;@javax.xml.ws.ResponseWrapper"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-ws-responsewrapper-outline">10.3.3.&nbsp;<code class="literal">@javax.xml.ws.ResponseWrapper</code></h4></div></div></div><p>This annotation annotates methods in the Service Endpoint
            Interface with the response wrapper bean to be used at
            runtime.</p><p>When starting from Java this annotation is used to resolve
            overloading conflicts in <code class="literal">DOCUMENT\LITERAL</code> mode.
            Only the <code class="literal">className</code> is required in this
            case.</p><div class="table"><a name="d0e5126"></a><p class="title"><b>Table&nbsp;11.&nbsp;<code class="literal">@javax.xml.ws.ResponseWrapper</code> -
                Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.ws.ResponseWrapper -&#xA;                Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">localName</code></p></td><td><p>Specifies the
                            <code class="literal">localName</code> of the XML Schema
                            element representing this request
                            wrapper.</p></td><td><p><code class="literal">operationName</code> as
                            defined by
                            <code class="literal">@javax.jws.WebMethod</code></p></td></tr><tr><td><p><code class="literal">targetNamespace</code></p></td><td><p>namespace of the request wrapper
                            element.</p></td><td><p>the <code class="literal">targetNamespace</code>
                            of the SEI</p></td></tr><tr><td><p><code class="literal">className</code></p></td><td><p>The name of the Class representing the
                            request wrapper.</p></td><td><p></p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.3.3.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-431093721276197">10.3.3.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Target(ElementType.METHOD)</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> ResponseWrapper {
    <span class="Comment">/**
     * Elements local name.
     */</span>
    <span class="ReservedWord">public</span> String localName() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * Elements namespace name.
     */</span>
    <span class="ReservedWord">public</span> String targetNamespace() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * Request wrapper bean name.
     */</span>
    <span class="ReservedWord">public</span> String className() <span class="ReservedWord">default</span> <span class="String">""</span>;
}</pre></div></div><div class="section" title="10.3.3.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-486634908061201">10.3.3.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e5195"></a><p class="title"><b>Example&nbsp;15.&nbsp;<code class="literal">@javax.xml.ws.ResponseWrapper</code> -
                    Example</b></p><div class="example-contents"><pre class="programlisting"><span class="ReservedWord">public</span> <span class="ReservedWord">interface</span> AddNumbersImpl {
    <span class="Comment">/**
     * @param arg1
     * @param arg0
     * @return returns int
     * @throws AddNumbersException_Exception
     */</span>
    <span class="Annotation">@WebMethod</span>
    <span class="Annotation">@WebResult(targetNamespace = "")</span>
    <span class="Annotation">@RequestWrapper(localName = "addNumbers", 
            targetNamespace = "http://server.fromjava/", 
            className = "fromjava.client.AddNumbers")</span>
    <span class="Annotation">@ResponseWrapper(localName = "addNumbersResponse",
            targetNamespace = "http://server.fromjava/", 
            className = "fromjava.client.AddNumbersResponse")</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="Annotation">@WebParam(name = "arg0", targetNamespace = "")</span> 
                              <span class="ReservedWord">int</span> arg0, <span class="Annotation">@WebParam(name = "arg1", targetNamespace = "")</span> <span class="ReservedWord">int</span> arg1) <span class="ReservedWord">throws</span> AddNumbersException_Exception;
}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.3.4.&nbsp;@javax.xml.ws.ServiceMode"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-ws-servicemode-outline">10.3.4.&nbsp;<code class="literal">@javax.xml.ws.ServiceMode</code></h4></div></div></div><p>This annotation allows the <a class="xref" href="ch03.html#users-guide-provider" title="2.&nbsp;Provider">Provider</a>
            developer to indicate whether a <code class="literal">Provider</code>
            implementation wishes to work with entire protocol messages or
            just with protocol message payloads.</p><div class="table"><a name="d0e5213"></a><p class="title"><b>Table&nbsp;12.&nbsp;<code class="literal">@javax.xml.ws.ServiceMode</code> -
                Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.ws.ServiceMode -&#xA;                Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">value</code></p></td><td><p>Convey whether the
                            <code class="literal">Provider</code> endpoint wants to access
                            then entire message (<code class="literal">MESSAGE</code>) or
                            just the payload
                            (<code class="literal">PAYLOAD</code>).</p></td><td><p><code class="literal">PAYLOAD</code></p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.3.4.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-7509472401703894">10.3.4.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Target({ElementType.TYPE})</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Inherited</span>
<span class="Annotation">@Documented</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> ServiceMode {
    <span class="Comment">/**
     * Service mode. &lt;code&gt;PAYLOAD&lt;/code&gt; indicates that the 
     * &lt;code&gt;Provider&lt;/code&gt; implementation
     * wishes to work with protocol message payloads only. 
     * &lt;code&gt;MESSAGE&lt;/code&gt; indicates
     * that the &lt;code&gt;Provider&lt;/code&gt; implementation wishes to work with 
     * entire protocol
     * messages.
     */</span>
    <span class="ReservedWord">public</span> Service.Mode value() <span class="ReservedWord">default</span> Service.Mode.PAYLOAD;
}</pre></div></div><div class="section" title="10.3.4.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-0843754606554705">10.3.4.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e5261"></a><p class="title"><b>Example&nbsp;16.&nbsp;<code class="literal">@javax.xml.ws.ServiceMode</code> -
                    Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@ServiceMode(value = Service.Mode.PAYLOAD)</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl <span class="ReservedWord">implements</span> Provider&lt;Source&gt; {
    <span class="ReservedWord">public</span> Source invoke(Source source) <span class="ReservedWord">throws</span> RemoteException {
        <span class="ReservedWord">try</span> {
            DOMResult dom = <span class="ReservedWord">new</span> DOMResult();
            Transformer trans = TransformerFactory.newInstance()
                    .newTransformer();
            trans.transform(source, dom);
            Node node = dom.getNode();
            Node root = node.getFirstChild();
            Node first = root.getFirstChild();
            <span class="ReservedWord">int</span> number1 = Integer.decode(first.getFirstChild()
                    .getNodeValue());
            Node second = first.getNextSibling();
            <span class="ReservedWord">int</span> number2 = Integer.decode(second.getFirstChild()
                    .getNodeValue());
            <span class="ReservedWord">return</span> sendSource(number1, number2);
        } <span class="ReservedWord">catch</span> (Exception e) {
            e.printStackTrace();
            <span class="ReservedWord">throw</span> <span class="ReservedWord">new</span> RemoteException(<span class="String">"Error in provider endpoint"</span>);
        }
    }

    <span class="ReservedWord">private</span> Source sendSource(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) {
        <span class="ReservedWord">int</span> sum = number1 + number2;
        String body = <span class="String">"&lt;ns:addNumbersResponse xmlns:ns =\"http://duke"</span> +
                <span class="String">".example.org\"&gt;&lt;return&gt;"</span> + sum +
                <span class="String">"&lt;/return&gt;&lt;/ns:addNumbersResponse&gt;"</span>;
        Source source = <span class="ReservedWord">new</span> StreamSource(<span class="ReservedWord">new</span> ByteArrayInputStream(body.getBytes()));
        <span class="ReservedWord">return</span> source;
    }
}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.3.5.&nbsp;@javax.xml.ws.WebEndpoint"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-ws-webendpoint-outline">10.3.5.&nbsp;<code class="literal">@javax.xml.ws.WebEndpoint</code></h4></div></div></div><p>Used to annotate the <code class="literal">getPortName()</code>
            methods of a generated service interface.</p><p>The information specified in this annotation is sufficient
            to uniquely identify a <code class="literal">wsdl:port</code> element inside
            a <code class="literal">wsdl:service</code>. The latter is determined based
            on the value of the <code class="literal">WebServiceClient</code> annotation
            on the generated service interface itself.</p><div class="table"><a name="d0e5288"></a><p class="title"><b>Table&nbsp;13.&nbsp;<code class="literal">@javax.xml.ws.WebEndpoint</code> -
                Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.ws.WebEndpoint -&#xA;                Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">name</code></p></td><td><p>Defines the local name of the XML
                            element representing the corresponding port in the
                            WSDL.</p></td><td><p>""</p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.3.5.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-800546080791241">10.3.5.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Comment">/**
 * Used to annotate the &lt;code&gt;get&lt;em&gt;PortName&lt;/em&gt;()&lt;/code&gt;
 * methods of a generated service interface.
 * &lt;p/&gt;
 * &lt;p&gt;The information specified in this annotation is sufficient
 * to uniquely identify a &lt;code&gt;wsdl:port&lt;/code&gt; element
 * inside a &lt;code&gt;wsdl:service&lt;/code&gt;. The latter is
 * determined based on the value of the &lt;code&gt;WebServiceClient&lt;/code&gt;
 * annotation on the generated service interface itself.
 *
 * @see javax.xml.ws.WebServiceClient
 * @since JAX-WS 2.0
 */</span>
<span class="Annotation">@Target({ElementType.METHOD})</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Documented</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> WebEndpoint {
    <span class="Comment">/**
     * The local name of the endpoint.
     */</span>
    String name() <span class="ReservedWord">default</span> <span class="String">""</span>;
}</pre></div></div><div class="section" title="10.3.5.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-969119628218757">10.3.5.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e5326"></a><p class="title"><b>Example&nbsp;17.&nbsp;<code class="literal">@javax.xml.ws.WebEndpoint</code> -
                    Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebServiceClient(name = "AddNumbersImplService", 
        targetNamespace = "http://server.fromjava/", 
        wsdlLocation = "http://localhost:8080/jaxws-fromjava/addnumbers" +
                "?wsdl")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImplService <span class="ReservedWord">extends</span> Service {
    <span class="ReservedWord">private</span> <span class="ReservedWord">final</span> <span class="ReservedWord">static</span> URL WSDL_LOCATION;
    <span class="ReservedWord">private</span> <span class="ReservedWord">final</span> <span class="ReservedWord">static</span> QName ADDNUMBERSIMPLSERVICE = <span class="ReservedWord">new</span> QName
            (<span class="String">"http://server.fromjava/"</span>, <span class="String">"AddNumbersImplService"</span>);
    <span class="ReservedWord">private</span> <span class="ReservedWord">final</span> <span class="ReservedWord">static</span> QName ADDNUMBERSIMPLPORT = <span class="ReservedWord">new</span> QName
            (<span class="String">"http://server.fromjava/"</span>, <span class="String">"AddNumbersImplPort"</span>);

    <span class="ReservedWord">static</span> {
        URL url = null;
        <span class="ReservedWord">try</span> {
            url = <span class="ReservedWord">new</span> URL(<span class="String">"http://localhost:8080/jaxws-fromjava"</span> +
                    <span class="String">"/addnumbers?wsdl"</span>);
        } <span class="ReservedWord">catch</span> (MalformedURLException e) {
            e.printStackTrace();
        }
        WSDL_LOCATION = url;
    }

    <span class="ReservedWord">public</span> AddNumbersImplService(URL wsdlLocation, QName serviceName) {
        <span class="ReservedWord">super</span>(wsdlLocation, serviceName);
    }

    <span class="ReservedWord">public</span> AddNumbersImplService() {
        <span class="ReservedWord">super</span>(WSDL_LOCATION, ADDNUMBERSIMPLSERVICE);
    }

    <span class="Comment">/**
     * @return returns AddNumbersImpl
     */</span>
    <span class="Annotation">@WebEndpoint(name = "AddNumbersImplPort")</span>
    <span class="ReservedWord">public</span> AddNumbersImpl getAddNumbersImplPort() {
        <span class="ReservedWord">return</span> (AddNumbersImpl) <span class="ReservedWord">super</span>.getPort(ADDNUMBERSIMPLPORT, AddNumbersImpl.<span class="ReservedWord">class</span>);
    }
}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.3.6.&nbsp;@javax.xml.ws.WebFault"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-ws-webfault-outline">10.3.6.&nbsp;<code class="literal">@javax.xml.ws.WebFault</code></h4></div></div></div><p>This annotation is generated by the JAX-WS tools into
            service specific exception classes generated from a WSDL to
            customize the local and namespace name of the fault element and
            the name of the fault bean and to mark the service specific
            exception as one generated from WSDL. The reason that the JAX-WS
            needs to know if a service specific exception is generated from a
            WSDL or not is because these exceptions will already have a fault
            bean generated for them. The name of this fault bean is not the
            same name as the one generated from a Java service specific
            exception class. For more information on this topic, please refer
            to section 3.6 of the <a class="link" href="http://www.jcp.org/en/jsr/detail?id=224" target="_top">JAX-WS
            2.0</a> specification.</p><div class="table"><a name="d0e5342"></a><p class="title"><b>Table&nbsp;14.&nbsp;<code class="literal">@javax.xml.ws.WebFault</code> - Description
                of Properties</b></p><div class="table-contents"><table summary="@javax.xml.ws.WebFault - Description&#xA;                of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">name</code></p></td><td><p>Defines the local name of the XML
                            element representing the corresponding fault in the
                            WSDL.</p></td><td><p>""</p></td></tr><tr><td><p><code class="literal">targetNamespace</code></p></td><td><p>Defines the namespace of the XML
                            element representing the corresponding fault in the
                            WSDL.</p></td><td><p>""</p></td></tr><tr><td><p><code class="literal">faultBean</code></p></td><td><p>The qualified name of the Java class
                            that represents the detail of the fault
                            message.</p></td><td><p>""</p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.3.6.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-4120261211514535">10.3.6.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Comment">/**
 * Used to annotate service specific exception classes to customize
 * to the local and namespace name of the fault element and the name
 * of the fault bean.
 *
 * @since JAX-WS 2.0
 */</span>
<span class="Annotation">@Target({ElementType.TYPE})</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Documented</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> WebFault {
    <span class="Comment">/**
     * Element's local name.
     */</span>
    <span class="ReservedWord">public</span> String name() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * Element's namespace name.
     */</span>
    <span class="ReservedWord">public</span> String targetNamespace() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * Fault bean name.
     */</span>
    <span class="ReservedWord">public</span> String faultBean() <span class="ReservedWord">default</span> <span class="String">""</span>;


    <span class="Comment">/**
     * wsdl:Message's name. Default name is the exception's class name.
     *
     * @since JAX-WS 2.2
     */</span>
    <span class="ReservedWord">public</span> String messageName() <span class="ReservedWord">default</span> <span class="String">""</span>;
}</pre></div></div><div class="section" title="10.3.6.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-36622117177507">10.3.6.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e5402"></a><p class="title"><b>Example&nbsp;18.&nbsp;<code class="literal">@javax.xml.ws.WebFault</code> -
                    Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@javax.xml.ws.WebFault(name = "AddNumbersException",
        targetNamespace = "http://server.fromjava/jaxws")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersException_Exception <span class="ReservedWord">extends</span> Exception {
    <span class="ReservedWord">private</span> fromjava.client.AddNumbersException faultInfo;

    <span class="ReservedWord">public</span> AddNumbersException_Exception(String message, 
                                         fromjava.client.AddNumbersException faultInfo) {
        <span class="ReservedWord">super</span>(message);
        <span class="ReservedWord">this</span>.faultInfo = faultInfo;
    }

    <span class="ReservedWord">public</span> AddNumbersException_Exception(String message, 
                                         fromjava.client
                                                 .AddNumbersException faultInfo, Throwable cause) {
        <span class="ReservedWord">super</span>(message, cause);
        <span class="ReservedWord">this</span>.faultInfo = faultInfo;
    }

    <span class="ReservedWord">public</span> fromjava.client.AddNumbersException getFaultInfo() {
        <span class="ReservedWord">return</span> faultInfo;
    }

}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.3.7.&nbsp;@javax.xml.ws.WebServiceClient"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-ws-webserviceclient-outline">10.3.7.&nbsp;<code class="literal">@javax.xml.ws.WebServiceClient</code></h4></div></div></div><p>The information specified in this annotation is sufficient
            to uniquely identify a <code class="literal">wsdl:service</code> element
            inside a WSDL document. This <code class="literal">wsdl:service</code>
            element represents the Web service for which the generated service
            interface provides a client view.</p><div class="table"><a name="d0e5421"></a><p class="title"><b>Table&nbsp;15.&nbsp;<code class="literal">@javax.xml.ws.WebServiceClient</code> -
                Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.ws.WebServiceClient -&#xA;                Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">name</code></p></td><td><p>Defines the local name of the
                            <code class="literal">wsdl:serviceName</code> in the
                            WSDL.</p></td><td><p>""</p></td></tr><tr><td><p><code class="literal">targetNamespace</code></p></td><td><p>Defines the namespace for the
                            <code class="literal">wsdl:serviceName</code> in the
                            WSDL.</p></td><td><p>""</p></td></tr><tr><td><p><code class="literal">wsdlLocation</code></p></td><td><p>Specifies the location of the WSDL that
                            defines this service.</p></td><td><p>""</p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.3.7.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-01521047797341">10.3.7.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Comment">/**
 * Used to annotate a generated service interface.
 * &lt;p/&gt;
 * &lt;p&gt;The information specified in this annotation is sufficient
 * to uniquely identify a &lt;code&gt;wsdl:service&lt;/code&gt;
 * element inside a WSDL document. This &lt;code&gt;wsdl:service&lt;/code&gt;
 * element represents the Web service for which the generated
 * service interface provides a client view.
 *
 * @since JAX-WS 2.0
 */</span>
<span class="Annotation">@Target({ElementType.TYPE})</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Documented</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> WebServiceClient {
    <span class="Comment">/**
     * The local name of the Web service.
     */</span>
    String name() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * The namespace for the Web service.
     */</span>
    String targetNamespace() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * The location of the WSDL document for the service (a URL).
     */</span>
    String wsdlLocation() <span class="ReservedWord">default</span> <span class="String">""</span>;
}</pre></div></div><div class="section" title="10.3.7.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-616559816681746">10.3.7.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e5487"></a><p class="title"><b>Example&nbsp;19.&nbsp;<code class="literal">@javax.xml.ws.WebServiceClient</code> -
                    Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebServiceClient(name = "AddNumbersImplService", 
        targetNamespace = "http://server.fromjava/", 
        wsdlLocation = "http://localhost:8080/jaxws-fromjava/addnumbers" +
                "?wsdl")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImplService <span class="ReservedWord">extends</span> Service {
    <span class="ReservedWord">private</span> <span class="ReservedWord">final</span> <span class="ReservedWord">static</span> URL WSDL_LOCATION;
    <span class="ReservedWord">private</span> <span class="ReservedWord">final</span> <span class="ReservedWord">static</span> QName ADDNUMBERSIMPLSERVICE = <span class="ReservedWord">new</span> QName
            (<span class="String">"http://server.fromjava/"</span>, <span class="String">"AddNumbersImplService"</span>);
    <span class="ReservedWord">private</span> <span class="ReservedWord">final</span> <span class="ReservedWord">static</span> QName ADDNUMBERSIMPLPORT = <span class="ReservedWord">new</span> QName
            (<span class="String">"http://server.fromjava/"</span>, <span class="String">"AddNumbersImplPort"</span>);

    <span class="ReservedWord">static</span> {
        URL url = null;
        <span class="ReservedWord">try</span> {
            url = <span class="ReservedWord">new</span> URL(<span class="String">"http://localhost:8080/jaxws-fromjava"</span> +
                    <span class="String">"/addnumbers?wsdl"</span>);
        } <span class="ReservedWord">catch</span> (MalformedURLException e) {
            e.printStackTrace();
        }
        WSDL_LOCATION = url;
    }

    <span class="ReservedWord">public</span> AddNumbersImplService(URL wsdlLocation, QName serviceName) {
        <span class="ReservedWord">super</span>(wsdlLocation, serviceName);
    }

    <span class="ReservedWord">public</span> AddNumbersImplService() {
        <span class="ReservedWord">super</span>(WSDL_LOCATION, ADDNUMBERSIMPLSERVICE);
    }

    <span class="Comment">/**
     * @return returns AddNumbersImpl
     */</span>
    <span class="Annotation">@WebEndpoint(name = "AddNumbersImplPort")</span>
    <span class="ReservedWord">public</span> AddNumbersImpl getAddNumbersImplPort() {
        <span class="ReservedWord">return</span> (AddNumbersImpl) <span class="ReservedWord">super</span>.getPort(ADDNUMBERSIMPLPORT, AddNumbersImpl.<span class="ReservedWord">class</span>);
    }
}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.3.8.&nbsp;@javax.xml.ws.WebServiceProvider"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-ws-webserviceprovider-outline">10.3.8.&nbsp;<code class="literal">@javax.xml.ws.WebServiceProvider</code></h4></div></div></div><p>Annotation used to annotate a <code class="literal">Provider</code>
            implementation class.</p><div class="table"><a name="d0e5503"></a><p class="title"><b>Table&nbsp;16.&nbsp;<code class="literal">@javax.xml.ws.WebServiceProvider</code> -
                Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.ws.WebServiceProvider -&#xA;                Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">targetNamespace</code></p></td><td><p>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.</p></td><td><p>The namespace mapped from the package
                            name containing the web service according to section
                            3.2 of the <a class="link" href="http://www.jcp.org/en/jsr/detail?id=224" target="_top">JAX-WS
                            2.0</a> specification.</p></td></tr><tr><td><p><code class="literal">serviceName</code></p></td><td><p>The Service name of the web service:
                            <code class="literal">wsdl:service</code></p></td><td><p>The unqualified name of the Java class
                            or interface + "Service"</p></td></tr><tr><td><p><code class="literal">portName</code></p></td><td><p>The
                            <code class="literal">wsdl:portName</code></p></td><td><p></p></td></tr><tr><td><p><code class="literal">wsdlLocation</code></p></td><td><p>Location of the WSDL description for
                            the service</p></td><td><p></p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.3.8.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-194282375923834">10.3.8.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Comment">/**
 * Used to annotate a Provider implementation class.
 *
 * @since JAX-WS 2.0
 * @see javax.xml.ws.Provider
 */</span>
<span class="Annotation">@Target(ElementType.TYPE)</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Documented</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> WebServiceProvider {
    <span class="Comment">/**
     * Location of the WSDL description for the service.
     */</span>
    String wsdlLocation() <span class="ReservedWord">default</span> <span class="String">""</span>;    
    
    <span class="Comment">/**
     * Service name.
     */</span>
    String serviceName() <span class="ReservedWord">default</span> <span class="String">""</span>;
    
    <span class="Comment">/**
     * Target namespace for the service
     */</span>
    String targetNamespace() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * Port name.
     */</span>
    String portName() <span class="ReservedWord">default</span> <span class="String">""</span>;
}</pre></div></div><div class="section" title="10.3.8.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-5041062451497706">10.3.8.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e5579"></a><p class="title"><b>Example&nbsp;20.&nbsp;<code class="literal">@javax.xml.ws.WebServiceProvider</code>
                    - Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@ServiceMode(value = Service.Mode.PAYLOAD)</span>
<span class="Annotation">@WebServiceProvider(wsdlLocation = "WEB-INF/wsdl/AddNumbers.wsdl")</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl <span class="ReservedWord">implements</span> Provider {
    <span class="ReservedWord">public</span> Source invoke(Source source) {
        <span class="ReservedWord">try</span> {
            DOMResult dom = <span class="ReservedWord">new</span> DOMResult();
            Transformer trans = TransformerFactory.newInstance()
                    .newTransformer();
            trans.transform(source, dom);
            Node node = dom.getNode();
            Node root = node.getFirstChild();
            Node first = root.getFirstChild();
            <span class="ReservedWord">int</span> number1 = Integer.decode(first.getFirstChild()
                    .getNodeValue());
            Node second = first.getNextSibling();
            <span class="ReservedWord">int</span> number2 = Integer.decode(second.getFirstChild()
                    .getNodeValue());
            <span class="ReservedWord">return</span> sendSource(number1, number2);
        } <span class="ReservedWord">catch</span> (Exception e) {
            e.printStackTrace();
            <span class="ReservedWord">throw</span> <span class="ReservedWord">new</span> RuntimeException(<span class="String">"Error in provider endpoint"</span>, e);
        }
    }

    <span class="ReservedWord">private</span> Source sendSource(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) {
        <span class="ReservedWord">int</span> sum = number1 + number2;
        String body = <span class="String">""</span> + sum + <span class="String">""</span>;
        Source source = <span class="ReservedWord">new</span> StreamSource(<span class="ReservedWord">new</span> ByteArrayInputStream(body.getBytes()));
        <span class="ReservedWord">return</span> source;
    }
}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.3.9.&nbsp;@javax.xml.ws.WebServiceRef"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-ws-webserviceref-outline">10.3.9.&nbsp;<code class="literal">@javax.xml.ws.WebServiceRef</code></h4></div></div></div><p>The <code class="literal">WebServiceRef</code> annotation is used to
            define a reference to a web service and (optionally) an injection
            target for it. Web service references are resources in the Java EE
            5 sense.</p><div class="table"><a name="d0e5595"></a><p class="title"><b>Table&nbsp;17.&nbsp;<code class="literal">@javax.xml.ws.WebServiceRef</code> -
                Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.ws.WebServiceRef -&#xA;                Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">name</code></p></td><td><p>The JNDI name of the resource. For
                            field annotations, the default is the field name.
                            For method annotations, the default is the JavaBeans
                            property name corresponding to the method. For class
                            annotations, there is no default and this must be
                            specified.</p></td><td><p></p></td></tr><tr><td><p><code class="literal">type</code></p></td><td><p>The Java type of the resource. For
                            field annotations, the default is the type of the
                            field. For method annotations, the default is the
                            type of the JavaBeans property. For class
                            annotations, there is no default and this must be
                            specified.</p></td><td><p></p></td></tr><tr><td><p><code class="literal">mappedName</code></p></td><td><p>A product specific name that this
                            resource should be mapped to.</p></td><td><p></p></td></tr><tr><td><p><code class="literal">value</code></p></td><td><p>The service class, always a type
                            extending <code class="literal">javax.xml.ws.Service</code>.
                            This element must be specified whenever the type of
                            the reference is a service endpoint
                            interface.</p></td><td><p></p></td></tr><tr><td><p><code class="literal">wsdlLocation</code></p></td><td><p>Location of the WSDL description for
                            the service</p></td><td><p></p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.3.9.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-910589920332548">10.3.9.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Comment">/**
 * The &lt;code&gt;WebServiceRef&lt;/code&gt; annotation is used to
 * define a reference to a web service and
 * (optionally) an injection target for it.
 * It can be used to inject both service and proxy
 * instances. These injected references are not thread safe.
 * If the references are accessed by multiple threads,
 * usual synchronization techinques can be used to
 * support multiple threads.
 * &lt;p/&gt;
 * Web service references are resources in the Java EE 5 sense.
 * The annotations (for example, {@link Addressing}) annotated with
 * meta-annotation {@link WebServiceFeatureAnnotation}
 * can be used in conjunction with &lt;code&gt;WebServiceRef&lt;/code&gt;.
 * The created reference MUST be configured with annotation's web service
 * feature.
 * &lt;p/&gt;
 * If a JAX-WS implementation encounters an unsupported or unrecognized
 * annotation annotated with the &lt;code&gt;WebServiceFeatureAnnotation&lt;/code&gt;
 * that is specified with &lt;code&gt;WebServiceRef&lt;/code&gt;, 
 * an ERROR MUST be given.
 *
 * @see javax.annotation.Resource
 * @see WebServiceFeatureAnnotation
 * @since JAX-WS 2.0
 */</span>
<span class="Annotation">@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Documented</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> WebServiceRef {
    <span class="Comment">/**
     * The JNDI name of the resource.  For field annotations,
     * the default is the field name.  For method annotations,
     * the default is the JavaBeans property name corresponding
     * to the method.  For class annotations, there is no default
     * and this MUST be specified.
     * &lt;p/&gt;
     * The JNDI name can be absolute(with any logical namespace) or 
     * relative
     * to JNDI &lt;code&gt;java:comp/env&lt;/code&gt; namespace.
     */</span>
    String name() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * The Java type of the resource.  For field annotations,
     * the default is the type of the field.  For method annotations,
     * the default is the type of the JavaBeans property.
     * For class annotations, there is no default and this MUST be
     * specified.
     */</span>
    Class&lt;?&gt; type() <span class="ReservedWord">default</span> Object.<span class="ReservedWord">class</span>;

    <span class="Comment">/**
     * A product specific name that this resource should be mapped to.
     * The name of this resource, as defined by the &lt;code&gt;name&lt;/code&gt;
     * element or defaulted, is a name that is local to the application
     * component using the resource.  (When a relative JNDI name
     * is specified, then it's a name in the JNDI
     * &lt;code&gt;java:comp/env&lt;/code&gt; namespace.)  Many application servers
     * provide a way to map these local names to names of resources
     * known to the application server.  This mapped name is often a
     * &lt;i&gt;global&lt;/i&gt; JNDI name, but may be a name of any form.
     * &lt;p/&gt;
     * Application servers are not required to support any particular
     * form or type of mapped name, nor the ability to use mapped names.
     * The mapped name is product-dependent and often 
     * installation-dependent.
     * No use of a mapped name is portable.
     */</span>
    String mappedName() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * The service class, alwiays a type extending
     * &lt;code&gt;javax.xml.ws.Service&lt;/code&gt;. This element MUST be specified
     * whenever the type of the reference is a service endpoint interface.
     */</span>
    <span class="Comment">// 2.1 has Class value() default Object.class;</span>
    <span class="Comment">// Fixing this raw Class type correctly in 2.2 API. This shouldn't </span>
    <span class="Comment">// cause</span>
    <span class="Comment">// any compatibility issues for applications.</span>
    Class&lt;? <span class="ReservedWord">extends</span> Service&gt; value() <span class="ReservedWord">default</span> Service.<span class="ReservedWord">class</span>;

    <span class="Comment">/**
     * A URL pointing to the WSDL document for the web service.
     * If not specified, the WSDL location specified by annotations
     * on the resource type is used instead.
     */</span>
    String wsdlLocation() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * A portable JNDI lookup name that resolves to the target
     * web service reference.
     *
     * @since JAX-WS 2.2
     */</span>
    String lookup() <span class="ReservedWord">default</span> <span class="String">""</span>;

}</pre></div></div></div><div class="section" title="10.3.10.&nbsp;@javax.xml.ws.Action"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-ws-action-outline">10.3.10.&nbsp;<code class="literal">@javax.xml.ws.Action</code></h4></div></div></div><p>The <code class="literal">Action</code> annotation allows explicit
            association of <code class="literal">Action</code> message addressing
            property with <code class="literal">input</code>, <code class="literal">output</code>,
            and <code class="literal">fault</code> messages of the mapped WSDL
            operation.</p><p>This annotation can be specified on each method of a service
            endpoint interface or implementation. For such a method, the
            mapped operation in the generated WSDL contains explicit
            <code class="literal">wsaw:Action</code> attribute on the WSDL
            <code class="literal">input</code>, <code class="literal">output</code> and
            <code class="literal">fault</code> messages of the WSDL
            <code class="literal">operation</code> based upon which attributes of the
            <code class="literal">Action</code> annotation have been specified.</p><div class="table"><a name="d0e5713"></a><p class="title"><b>Table&nbsp;18.&nbsp;<code class="literal">@javax.xml.ws.Action</code> - Description
                of Properties</b></p><div class="table-contents"><table summary="@javax.xml.ws.Action - Description&#xA;                of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">input</code></p></td><td><p>Explicit value of
                            <code class="literal">Action</code> message addressing
                            property for the <code class="literal">input</code> message of
                            the operation. If the value is "", then no
                            <code class="literal">wsaw:Action</code> is
                            generated.</p></td><td><p>""</p></td></tr><tr><td><p><code class="literal">ouput</code></p></td><td><p>Explicit value of
                            <code class="literal">Action</code> message addressing
                            property for the <code class="literal">output</code> message
                            of the operation. If the value is "", then no
                            <code class="literal">wsaw:Action</code> is
                            generated.</p></td><td><p>""</p></td></tr><tr><td><p><code class="literal">fault</code></p></td><td><p>Explicit value of
                            <code class="literal">Action</code> message addressing
                            property for the <code class="literal">fault</code> message(s)
                            of the operation. Each exception that is mapped to a
                            fault and requires explicit
                            <code class="literal">Action</code> message addressing
                            property, need to be specified as a value in this
                            property using FaultAction
                            annotation.</p></td><td><p>{}</p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.3.10.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-51086889743311215">10.3.10.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Comment">/**
 * The &lt;code&gt;Action&lt;/code&gt; annotation allows explicit association of a
 * WS-Addressing &lt;code&gt;Action&lt;/code&gt; message addressing property with
 * &lt;code&gt;input&lt;/code&gt;, &lt;code&gt;output&lt;/code&gt;, and
 * &lt;code&gt;fault&lt;/code&gt; messages of the mapped WSDL operation.
 * &lt;p/&gt;
 * This annotation can be specified on each method of a service endpoint 
 * interface.
 * For such a method, the mapped operation in the generated WSDL's
 * &lt;code&gt;wsam:Action&lt;/code&gt; attribute on the WSDL &lt;code&gt;input&lt;/code&gt;,
 * &lt;code&gt;output&lt;/code&gt; and &lt;code&gt;fault&lt;/code&gt; messages of the WSDL 
 * &lt;code&gt;operation&lt;/code&gt;
 * is based upon which attributes of the &lt;code&gt;Action&lt;/code&gt; annotation 
 * have been specified.
 * For the exact computation of &lt;code&gt;wsam:Action&lt;/code&gt; values for the 
 * messages, refer
 * to the algorithm in the JAX-WS specification.
 *
 * @see FaultAction
 * @since JAX-WS 2.1
 */</span>

<span class="Annotation">@Documented</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target(ElementType.METHOD)</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> Action {
    <span class="Comment">/**
     * Explicit value of the WS-Addressing &lt;code&gt;Action&lt;/code&gt; message 
     * addressing property for the &lt;code&gt;input&lt;/code&gt;
     * message of the operation.
     */</span>
    String input() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * Explicit value of the WS-Addressing &lt;code&gt;Action&lt;/code&gt; message 
     * addressing property for the &lt;code&gt;output&lt;/code&gt;
     * message of the operation.
     */</span>
    String output() <span class="ReservedWord">default</span> <span class="String">""</span>;

    <span class="Comment">/**
     * Explicit value of the WS-Addressing &lt;code&gt;Action&lt;/code&gt; message 
     * addressing property for the &lt;code&gt;fault&lt;/code&gt;
     * message(s) of the operation. Each exception that is mapped to a 
     * fault and requires an explicit WS-Addressing
     * &lt;code&gt;Action&lt;/code&gt; message addressing property, 
     * needs to be specified as a value in this property
     * using {@link FaultAction} annotation.
     */</span>
    FaultAction[] fault() <span class="ReservedWord">default</span> {};
}</pre></div></div><div class="section" title="10.3.10.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-386040099353688">10.3.10.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e5800"></a><p class="title"><b>Example&nbsp;21.&nbsp;<code class="literal">@javax.xml.ws.Action</code> - Example 1
                    - Specify explicit values for <code class="literal">Action</code>
                    message addressing property for <code class="literal">input</code>
                    and <code class="literal">output</code> messages.</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@javax.jws.WebService</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl {
    <span class="Annotation">@javax.xml.ws.Action(
            input = "http://example.com/inputAction",
            output = "http://example.com/outputAction")</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) {
        <span class="ReservedWord">return</span> number1 + number2;
    }
}</pre><p>The generated WSDL looks like:</p><pre class="programlisting"><span class="ReservedWord">&lt;definitions</span> <span class="Identifier">targetNamespace</span>=<span class="String">"http://example.com/numbers"</span> <span class="Identifier">...&gt;</span>

    <span class="Identifier">...</span>
    
    <span class="Identifier">&lt;portType</span> <span class="Identifier">name</span>=<span class="String">"AddNumbersPortType"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;operation</span> <span class="Identifier">name</span>=<span class="String">"AddNumbers"</span><span class="ReservedWord">&gt;</span>
            <span class="ReservedWord">&lt;input</span> <span class="Identifier">message</span>=<span class="String">"tns:AddNumbersInput"</span> <span class="Identifier">name</span>=<span class="String">"Parameters"</span>
                    <span class="Identifier">wsaw:Action</span>=<span class="String">"http://example.com/inputAction"</span><span class="ReservedWord">/&gt;</span>
            <span class="ReservedWord">&lt;output</span> <span class="Identifier">message</span>=<span class="String">"tns:AddNumbersOutput"</span> <span class="Identifier">name</span>=<span class="String">"Result"</span>
                    <span class="Identifier">wsaw:Action</span>=<span class="String">"http://example.com/outputAction"</span><span class="ReservedWord">/&gt;</span>
        <span class="ReservedWord">&lt;/operation&gt;</span>
    <span class="ReservedWord">&lt;/portType&gt;</span>

    ...

<span class="ReservedWord">&lt;/definitions&gt;</span></pre></div></div><br class="example-break"><div class="example"><a name="d0e5820"></a><p class="title"><b>Example&nbsp;22.&nbsp;<code class="literal">@javax.xml.ws.Action</code> - Example 2
                    - Specify explicit value for <code class="literal">Action</code>
                    message addressing property for only the
                    <code class="literal">input</code> message.</b></p><div class="example-contents"><p>The default values are used for the
                    <code class="literal">output</code> message.</p><pre class="programlisting"><span class="Annotation">@javax.jws.WebService</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl {
    <span class="Annotation">@javax.xml.ws.Action(input = "http://example.com/inputAction")</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) {
        <span class="ReservedWord">return</span> number1 + number2;
    }
}</pre><p>The generated WSDL looks like:</p><pre class="programlisting"><span class="ReservedWord">&lt;definitions</span> <span class="Identifier">targetNamespace</span>=<span class="String">"http://example.com/numbers"</span> <span class="Identifier">...&gt;</span>

    <span class="Identifier">...</span>
    
    <span class="Identifier">&lt;portType</span> <span class="Identifier">name</span>=<span class="String">"AddNumbersPortType"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;operation</span> <span class="Identifier">name</span>=<span class="String">"AddNumbers"</span><span class="ReservedWord">&gt;</span>
            <span class="ReservedWord">&lt;input</span> <span class="Identifier">message</span>=<span class="String">"tns:AddNumbersInput"</span> <span class="Identifier">name</span>=<span class="String">"Parameters"</span>
                    <span class="Identifier">wsaw:Action</span>=<span class="String">"http://example.com/inputAction"</span><span class="ReservedWord">/&gt;</span>
            <span class="ReservedWord">&lt;output</span> <span class="Identifier">message</span>=<span class="String">"tns:AddNumbersOutput"</span> <span class="Identifier">name</span>=<span class="String">"Result"</span><span class="ReservedWord">/&gt;</span>
        <span class="ReservedWord">&lt;/operation&gt;</span>
    <span class="ReservedWord">&lt;/portType&gt;</span>
    
    ...
    
<span class="ReservedWord">&lt;/definitions&gt;</span></pre><p>It is legitimate to specify an explicit value for
                    <code class="literal">Action</code> message addressing property for
                    <code class="literal">output</code> message only. In this case, a
                    default value of <code class="literal">wsaw:Action</code> is used
                    for the <code class="literal">input</code> message.</p></div></div><br class="example-break"><div class="example"><a name="d0e5856"></a><p class="title"><b>Example&nbsp;23.&nbsp;<code class="literal">@javax.xml.ws.Action</code> - Example 3
                    - <code class="literal">@FaultAction</code></b></p><div class="example-contents"><p>See <code class="literal"><a class="xref" href="ch03.html#javax-xml-ws-faultaction-outline" title="10.3.11.&nbsp;@javax.xml.ws.FaultAction"><code class="literal">@javax.xml.ws.FaultAction</code></a></code> for an example of
                    how to specify an explicit value for
                    <code class="literal">Action</code> message addressing property for
                    the <code class="literal">fault</code> message.</p></div></div><br class="example-break"></div></div><div class="section" title="10.3.11.&nbsp;@javax.xml.ws.FaultAction"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-ws-faultaction-outline">10.3.11.&nbsp;<code class="literal">@javax.xml.ws.FaultAction</code></h4></div></div></div><p>The <code class="literal">FaultAction</code> annotation is used inside
            an <code class="literal">Action</code> annotation to allow an explicit
            association of <code class="literal">Action</code> message addressing
            property with the <code class="literal">fault</code> messages of the WSDL
            operation mapped from the exception class.</p><p>The <code class="literal">fault</code> message in the generated WSDL
            operation mapped for <code class="literal">className</code> class contains
            explicit <code class="literal">wsaw:Action</code> attribute.</p><div class="table"><a name="d0e5903"></a><p class="title"><b>Table&nbsp;19.&nbsp;<code class="literal">@javax.xml.ws.FaultAction</code> -
                Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.ws.FaultAction -&#xA;                Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">className</code></p></td><td><p>Name of the exception
                            class</p></td><td><p>there is no default and is
                            required.</p></td></tr><tr><td><p><code class="literal">value</code></p></td><td><p>Value of <code class="literal">Action</code>
                            message addressing property for the
                            exception</p></td><td><p>""</p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.3.11.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-2290523806237594">10.3.11.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Documented</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target(ElementType.METHOD)</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> FaultAction {
    <span class="Comment">/**
     * Name of the exception class
     */</span>
    Class&lt;? <span class="ReservedWord">extends</span> Exception&gt; className();

    <span class="Comment">/**
     * Value of WS-Addressing &lt;code&gt;Action&lt;/code&gt; message addressing 
     * property for the exception
     */</span>
    String value() <span class="ReservedWord">default</span> <span class="String">""</span>;
}</pre></div></div><div class="section" title="10.3.11.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-139653992039007">10.3.11.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e5955"></a><p class="title"><b>Example&nbsp;24.&nbsp;<code class="literal">@javax.xml.ws.FaultAction</code> -
                    Example 1 - Specify explicit values for
                    <code class="literal">Action</code> message addressing property for
                    the <code class="literal">input</code>, <code class="literal">output</code>
                    and <code class="literal">fault</code> message if the Java method
                    throws only one service specific exception.</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@javax.jws.WebService</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl {
    <span class="Annotation">@javax.xml.ws.Action(
            input = "http://example.com/inputAction",
            output = "http://example.com/outputAction",
            fault = {
                    @javax.xml.ws.FaultAction(className = 
                            AddNumbersException.class,
                            value = "http://example.com/faultAction")})</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            AddNumbersException {
        <span class="ReservedWord">return</span> number1 + number2;
    }
}</pre><p>The generated WSDL looks like:</p><pre class="programlisting"><span class="ReservedWord">&lt;definitions</span> <span class="Identifier">targetNamespace</span>=<span class="String">"http://example.com/numbers"</span> <span class="Identifier">...&gt;</span>

    <span class="Identifier">...</span>
    
    <span class="Identifier">&lt;portType</span> <span class="Identifier">name</span>=<span class="String">"AddNumbersPortType"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;operation</span> <span class="Identifier">name</span>=<span class="String">"AddNumbers"</span><span class="ReservedWord">&gt;</span>
            <span class="ReservedWord">&lt;input</span> <span class="Identifier">message</span>=<span class="String">"tns:AddNumbersInput"</span> <span class="Identifier">name</span>=<span class="String">"Parameters"</span>
                    <span class="Identifier">wsaw:Action</span>=<span class="String">"http://example.com/inputAction"</span><span class="ReservedWord">/&gt;</span>
            <span class="ReservedWord">&lt;output</span> <span class="Identifier">message</span>=<span class="String">"tns:AddNumbersOutput"</span> <span class="Identifier">name</span>=<span class="String">"Result"</span>
                    <span class="Identifier">wsaw:Action</span>=<span class="String">"http://example.com/outputAction"</span><span class="ReservedWord">/&gt;</span>
            <span class="ReservedWord">&lt;fault</span> <span class="Identifier">message</span>=<span class="String">"tns:AddNumbersException"</span>
                    <span class="Identifier">name</span>=<span class="String">"AddNumbersException"</span>
                    <span class="Identifier">wsaw:Action</span>=<span class="String">"http://example.com/faultAction"</span><span class="ReservedWord">/&gt;</span>
        <span class="ReservedWord">&lt;/operation&gt;</span>
    <span class="ReservedWord">&lt;/portType&gt;</span>
    
    ...
    
<span class="ReservedWord">&lt;/definitions&gt;</span></pre></div></div><br class="example-break"><div class="example"><a name="d0e5978"></a><p class="title"><b>Example&nbsp;25.&nbsp;<code class="literal">@javax.xml.ws.FaultAction</code> -
                    Example 1 - Specify explicit values for
                    <code class="literal">Action</code> message addressing property if
                    the Java method throws only one service specific
                    exception, without specifying the values for
                    <code class="literal">input</code> and <code class="literal">output</code>
                    messages.</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@javax.jws.WebService</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl {
    <span class="Annotation">@javax.xml.ws.Action(
            fault = {@javax.xml.ws.FaultAction(className = 
                    AddNumbersException.class,
                    value = "http://example.com/faultAction")})</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> 
            AddNumbersException {
        <span class="ReservedWord">return</span> number1 + number2;
    }
}</pre><p>The generated WSDL looks like:</p><pre class="programlisting"><span class="ReservedWord">&lt;definitions</span> <span class="Identifier">targetNamespace</span>=<span class="String">"http://example.com/numbers"</span> <span class="Identifier">...&gt;</span>
    
    <span class="Identifier">...</span>
    
    <span class="Identifier">&lt;portType</span> <span class="Identifier">name</span>=<span class="String">"AddNumbersPortType"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;operation</span> <span class="Identifier">name</span>=<span class="String">"AddNumbers"</span><span class="ReservedWord">&gt;</span>
            <span class="ReservedWord">&lt;input</span> <span class="Identifier">message</span>=<span class="String">"tns:AddNumbersInput"</span> <span class="Identifier">name</span>=<span class="String">"Parameters"</span><span class="ReservedWord">/&gt;</span>
            <span class="ReservedWord">&lt;output</span> <span class="Identifier">message</span>=<span class="String">"tns:AddNumbersOutput"</span> <span class="Identifier">name</span>=<span class="String">"Result"</span><span class="ReservedWord">/&gt;</span>
            <span class="ReservedWord">&lt;fault</span> <span class="Identifier">message</span>=<span class="String">"tns:addNumbersFault"</span> <span class="Identifier">name</span>=<span class="String">"InvalidNumbers"</span>
                    <span class="Identifier">wsa:Action</span>=<span class="String">"http://example.com/addnumbers/fault"</span><span class="ReservedWord">/&gt;</span>
        <span class="ReservedWord">&lt;/operation&gt;</span>
    <span class="ReservedWord">&lt;/portType&gt;</span>
    
    ...
    
<span class="ReservedWord">&lt;/definitions&gt;</span></pre></div></div><br class="example-break"><div class="example"><a name="d0e5998"></a><p class="title"><b>Example&nbsp;26.&nbsp;<code class="literal">@javax.xml.ws.FaultAction</code> -
                    Example 1 - Specify explicit values for
                    <code class="literal">Action</code> message addressing property if
                    the Java method throws more than one service specific
                    exception.</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@javax.jws.WebService</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl {
    <span class="Annotation">@javax.xml.ws.Action(
            fault = {@javax.xml.ws.FaultAction(className = 
                    AddNumbersException.class,
                    value = "http://example.com/addFaultAction"),

                    @javax.xml.ws.FaultAction(className = 
                            TooBigNumbersException.class,
                            value = "http://example" +
                                    ".com/toobigFaultAction")})</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> AddNumbersException, TooBigNumbersException {
        <span class="ReservedWord">return</span> number1 + number2;
    }
}</pre><p>The generated WSDL looks like:</p><pre class="programlisting"><span class="ReservedWord">&lt;definitions</span> <span class="Identifier">targetNamespace</span>=<span class="String">"http://example.com/numbers"</span> <span class="Identifier">...&gt;</span>
    
    <span class="Identifier">...</span>
    
    <span class="Identifier">&lt;portType</span> <span class="Identifier">name</span>=<span class="String">"AddNumbersPortType"</span><span class="ReservedWord">&gt;</span>
        <span class="ReservedWord">&lt;operation</span> <span class="Identifier">name</span>=<span class="String">"AddNumbers"</span><span class="ReservedWord">&gt;</span>
            <span class="ReservedWord">&lt;input</span> <span class="Identifier">message</span>=<span class="String">"tns:AddNumbersInput"</span> <span class="Identifier">name</span>=<span class="String">"Parameters"</span><span class="ReservedWord">/&gt;</span>
            <span class="ReservedWord">&lt;output</span> <span class="Identifier">message</span>=<span class="String">"tns:AddNumbersOutput"</span> <span class="Identifier">name</span>=<span class="String">"Result"</span><span class="ReservedWord">/&gt;</span>
            <span class="ReservedWord">&lt;fault</span> <span class="Identifier">message</span>=<span class="String">"tns:addNumbersFault"</span> <span class="Identifier">name</span>=<span class="String">"AddNumbersException"</span>
                    <span class="Identifier">wsa:Action</span>=<span class="String">"http://example.com/addnumbers/fault"</span><span class="ReservedWord">/&gt;</span>
            <span class="ReservedWord">&lt;fault</span> <span class="Identifier">message</span>=<span class="String">"tns:tooBigNumbersFault"</span>
                    <span class="Identifier">name</span>=<span class="String">"TooBigNumbersException"</span>
                    <span class="Identifier">wsa:Action</span>=<span class="String">"http://example.com/toobigFaultAction"</span><span class="ReservedWord">/&gt;</span>
        <span class="ReservedWord">&lt;/operation&gt;</span>
    <span class="ReservedWord">&lt;/portType&gt;</span>
    
    ...
    
<span class="ReservedWord">&lt;/definitions&gt;</span></pre></div></div><br class="example-break"></div></div></div><div class="section" title="10.4.&nbsp;JSR 222 (JAXB) Annotations"><div class="titlepage"><div><div><h3 class="title" id="jsr-222-jaxb-annotations-outline">10.4.&nbsp;JSR 222 (JAXB) Annotations</h3></div></div></div><p>The following JAXB annotations are being documented because
        JAX-WS generates them when generating wrapper beans and exception
        beans according to the JAX-WS 2.0 spec. Please refer to sections
        3.5.2.1 and 3.6 of the <a class="link" href="http://www.jcp.org/en/jsr/detail?id=224" target="_top">JAX-WS 2.0</a>
        specification for more information on these beans. For more
        information on these and other JAXB annotations please refer to the
        <a class="link" href="http://www.jcp.org/en/jsr/detail?id=222" target="_top">JAXB 2.0
        specification</a>.</p><div class="section" title="10.4.1.&nbsp;@javax.xml.bind.annotation.XmlRootElement"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-bind-annotation-xmlrootelement-outline">10.4.1.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlRootElement</code></h4></div></div></div><p>This annotation is used to map a top level class to a global
            element in the XML schema used by the WSDL of the web
            service.</p><div class="table"><a name="d0e6029"></a><p class="title"><b>Table&nbsp;20.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlRootElement</code>
                - Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.bind.annotation.XmlRootElement&#xA;                - Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">name</code></p></td><td><p>Defines the local name of the XML
                            element representing the annotated
                            class</p></td><td><code class="literal">##default</code> &#8211; the name is
                            derived from the class</td></tr><tr><td><p><code class="literal">namespace</code></p></td><td><p>Defines the namespace of the XML
                            element representing the annotated
                            class</p></td><td><code class="literal">##default</code> &#8211; the namespace
                            is derived from the package of the class</td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.4.1.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-638165859587004">10.4.1.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target({ElementType.TYPE})</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> XmlRootElement {
    <span class="Comment">/**
     * namespace name of the XML element.
     * &lt;p/&gt;
     * If the value is "##default", then the XML namespace name is
     * derived
     * from the package of the class ( {@link XmlSchema} ). If the
     * package is unnamed, then the XML namespace is the default
     * empty
     * namespace.
     */</span>
    String namespace() <span class="ReservedWord">default</span> <span class="String">"##default"</span>;

    <span class="Comment">/**
     * local name of the XML element.
     * &lt;p/&gt;
     * If the value is "##default", then the name is derived from
     * the
     * class name.
     */</span>
    String name() <span class="ReservedWord">default</span> <span class="String">"##default"</span>;

}</pre></div></div><div class="section" title="10.4.1.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-3077451588388276">10.4.1.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e6080"></a><p class="title"><b>Example&nbsp;27.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlRootElement</code>
                    - Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@XmlRootElement(name = "addNumbers", namespace = "http://server.fromjava/")</span>
<span class="Annotation">@XmlAccessorType(XmlAccessType.FIELD)</span>
<span class="Annotation">@XmlType(name = "addNumbers", namespace = "http://server.fromjava/", 
        propOrder = {"arg0", "arg1"})</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbers {

    <span class="Annotation">@XmlElement(name = "arg0", namespace = "")</span>
    <span class="ReservedWord">private</span> <span class="ReservedWord">int</span> arg0;
    <span class="Annotation">@XmlElement(name = "arg1", namespace = "")</span>
    <span class="ReservedWord">private</span> <span class="ReservedWord">int</span> arg1;

    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> getArg0() {
        <span class="ReservedWord">return</span> <span class="ReservedWord">this</span>.arg0;
    }

    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> setArg0(<span class="ReservedWord">int</span> arg0) {
        <span class="ReservedWord">this</span>.arg0 = arg0;
    }

    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> getArg1() {
        <span class="ReservedWord">return</span> <span class="ReservedWord">this</span>.arg1;
    }

    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> setArg1(<span class="ReservedWord">int</span> arg1) {
        <span class="ReservedWord">this</span>.arg1 = arg1;
    }
}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.4.2.&nbsp;@javax.xml.bind.annotation.XmlAccessorType"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-bind-annotation-xmlaccessortype-outline">10.4.2.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlAccessorType</code></h4></div></div></div><p>This annotation is used to specify whether fields or
            properties are serialized by default.</p><div class="table"><a name="d0e6093"></a><p class="title"><b>Table&nbsp;21.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlAccessorType</code>
                - Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.bind.annotation.XmlAccessorType&#xA;                - Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">value</code></p></td><td><p>Specifies whether fields or properties
                            are serialized by default. The value can be
                            <code class="literal">XmlAccessType.FIELD</code> or
                            <code class="literal">XmlAccessType.PROPERTY</code> or
                            <code class="literal">XmlAccessType.PUBLIC_MEMBER</code> or
                            <code class="literal">XmlAccessType.NONE</code></p></td><td><p><code class="literal">XmlAccessType.PROPERTY</code></p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.4.2.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-9211410647210394">10.4.2.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Inherited</span>
<span class="Annotation">@Retention(RUNTIME)</span>
<span class="Annotation">@Target({PACKAGE, TYPE})</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> XmlAccessorType {

    <span class="Comment">/**
     * Specifies whether fields or properties are serialized.
     *
     * @see XmlAccessType
     */</span>
    XmlAccessType value() <span class="ReservedWord">default</span> XmlAccessType.PUBLIC_MEMBER;
}</pre><pre class="programlisting"><span class="Comment">/**
 * Used by XmlAccessorType to control serialization of fields or
 * properties.
 */</span>
<span class="ReservedWord">public</span> enum XmlAccessType {
    <span class="Comment">/**
     * Every getter/setter pair in a JAXB-bound class will be
     * automatically
     * bound to XML, unless annotated by {@link XmlTransient}.
     * &lt;p/&gt;
     * Fields are bound to XML only when they are explicitly
     * annotated
     * by some of the JAXB annotations.
     */</span>
    PROPERTY,
    <span class="Comment">/**
     * Every non static, non transient field in a JAXB-bound class
     * will be automatically
     * bound to XML, unless annotated by {@link XmlTransient}.
     * &lt;p/&gt;
     * Getter/setter pairs are bound to XML only when they are
     * explicitly annotated
     * by some of the JAXB annotations.
     */</span>
    FIELD,
    <span class="Comment">/**
     * Every public getter/setter pair and every public field will
     * be
     * automatically bound to XML, unless annotated by {@link
     * XmlTransient}.
     * &lt;p/&gt;
     * Fields or getter/setter pairs that are private, protected,
     * or
     * defaulted to package-only access are bound to XML only when
     * they are
     * explicitly annotated by the appropriate JAXB annotations.
     */</span>
    PUBLIC_MEMBER,
    <span class="Comment">/**
     * None of the fields or properties is bound to XML unless they
     * are specifically  annotated with some of the JAXB
     * annotations.
     */</span>
    NONE
}</pre></div></div><div class="section" title="10.4.2.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-6109125632205346">10.4.2.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e6145"></a><p class="title"><b>Example&nbsp;28.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlAccessorType</code>
                    - Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@XmlRootElement(name = "addNumbers", namespace = "http://server.fromjava/")</span>
<span class="Annotation">@XmlAccessorType(XmlAccessType.FIELD)</span>
<span class="Annotation">@XmlType(name = "addNumbers", namespace = "http://server.fromjava/", 
        propOrder = {"arg0", "arg1"})</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbers {

    <span class="Annotation">@XmlElement(name = "arg0", namespace = "")</span>
    <span class="ReservedWord">private</span> <span class="ReservedWord">int</span> arg0;
    <span class="Annotation">@XmlElement(name = "arg1", namespace = "")</span>
    <span class="ReservedWord">private</span> <span class="ReservedWord">int</span> arg1;

    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> getArg0() {
        <span class="ReservedWord">return</span> <span class="ReservedWord">this</span>.arg0;
    }

    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> setArg0(<span class="ReservedWord">int</span> arg0) {
        <span class="ReservedWord">this</span>.arg0 = arg0;
    }

    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> getArg1() {
        <span class="ReservedWord">return</span> <span class="ReservedWord">this</span>.arg1;
    }

    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> setArg1(<span class="ReservedWord">int</span> arg1) {
        <span class="ReservedWord">this</span>.arg1 = arg1;
    }
}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.4.3.&nbsp;@javax.xml.bind.annotation.XmlType"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-bind-annotation-xmltype-outline">10.4.3.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlType</code></h4></div></div></div><p>This annotation is used to map a value class to an XML
            Schema type. A value class is a data container for values
            represented by properties and fields. A schema type is a data
            container for values represented by schema components within a
            schema type's content model (e.g. Model groups, attributes
            etc).</p><div class="table"><a name="d0e6158"></a><p class="title"><b>Table&nbsp;22.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlType</code> -
                Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.bind.annotation.XmlType -&#xA;                Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">name</code></p></td><td><p>Defines the local name of the XML type
                            representing this class in the XML schema used by
                            the WSDL of the web service</p></td><td>"<code class="literal">##default</code>"</td></tr><tr><td><p><code class="literal">namespace</code></p></td><td><p>Defines the namespace of the XML type
                            representing this class in the XML schema used by
                            the WSDL of the web service</p></td><td>"<code class="literal">##default</code>"</td></tr><tr><td><p><code class="literal">propOrder</code></p></td><td><p>Defines a list of names of JavaBean
                            properties in the class. Each name in the list is
                            the name of a Java identifier of the JavaBean
                            property. The order in which JavaBean properties are
                            listed is the order of XML Schema elements to which
                            the JavaBean properties are mapped.</p><p>All
                            of the JavaBean properties being mapped must be
                            listed (i.e. if a JavaBean property mapping is
                            prevented by <code class="literal">@XmlTransient</code> then
                            it does not have to be listed). Otherwise, it is an
                            error. By default, the JavaBean properties are
                            ordered using a default order specified in the <a class="link" href="http://www.jcp.org/en/jsr/detail?id=222" target="_top">JAXB
                            2.0 specification</a>.</p></td><td><p>{""}</p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.4.3.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-7314416209576604">10.4.3.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target({ElementType.TYPE})</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> XmlType {
    <span class="Comment">/**
     * Name of the XML Schema type which the class is mapped.
     */</span>
    String name() <span class="ReservedWord">default</span> <span class="String">"##default"</span>;

    <span class="Comment">/**
     * Specifies the order for XML Schema elements when class is
     * mapped to a XML Schema complex type.
     * &lt;p/&gt;
     * &lt;p&gt; Refer to the table for how the propOrder affects the
     * mapping of class &lt;/p&gt;
     * &lt;p/&gt;
     * &lt;p&gt; The propOrder is a list of names of JavaBean properties in
     * the class. Each name in the list is the name of a Java
     * identifier of the JavaBean property. The order in which
     * JavaBean properties are listed is the order of XML Schema
     * elements to which the JavaBean properties are mapped. &lt;/p&gt;
     * &lt;p&gt; All of the JavaBean properties being mapped to XML Schema
     * elements
     * must be listed.
     * &lt;p&gt; A JavaBean property or field listed in propOrder must not
     * be transient or annotated with &lt;tt&gt;@XmlTransient&lt;/tt&gt;.
     * &lt;p&gt; The default ordering of JavaBean properties is determined
     * by @{@link XmlAccessorOrder}.
     */</span>
    String[] propOrder() <span class="ReservedWord">default</span> {<span class="String">""</span>};

    <span class="Comment">/**
     * Name of the target namespace of the XML Schema type. By
     * default, this is the target namespace to which the package
     * containing the class is mapped.
     */</span>
    String namespace() <span class="ReservedWord">default</span> <span class="String">"##default"</span>;

    <span class="Comment">/**
     * Class containing a no-arg factory method for creating an
     * instance of this class. The default is this class.
     * &lt;p/&gt;
     * &lt;p&gt;If &lt;tt&gt;factoryClass&lt;/tt&gt; is DEFAULT.class and
     * &lt;tt&gt;factoryMethod&lt;/tt&gt; is "", then there is no static factory
     * method.
     * &lt;p/&gt;
     * &lt;p&gt;If &lt;tt&gt;factoryClass&lt;/tt&gt; is DEFAULT.class and
     * &lt;tt&gt;factoryMethod&lt;/tt&gt; is not "", then
     * &lt;tt&gt;factoryMethod&lt;/tt&gt; is the name of a static factory method
     * in this class.
     * &lt;p/&gt;
     * &lt;p&gt;If &lt;tt&gt;factoryClass&lt;/tt&gt; is not DEFAULT.class, then
     * &lt;tt&gt;factoryMethod&lt;/tt&gt; must not be "" and must be the name of
     * a static factory method specified in &lt;tt&gt;factoryClass&lt;/tt&gt;.
     */</span>
    Class factoryClass() <span class="ReservedWord">default</span> DEFAULT.<span class="ReservedWord">class</span>;

    <span class="Comment">/**
     * Used in {@link XmlType#factoryClass()} to
     * signal that either factory mehod is not used or
     * that it's in the class with this {@link XmlType} itself.
     */</span>
    <span class="ReservedWord">static</span> <span class="ReservedWord">final</span> <span class="ReservedWord">class</span> DEFAULT {
    }

    <span class="Comment">/**
     * Name of a no-arg factory method in the class specified in
     * &lt;tt&gt;factoryClass&lt;/tt&gt; factoryClass().
     */</span>
    String factoryMethod() <span class="ReservedWord">default</span> <span class="String">""</span>;
}</pre></div></div><div class="section" title="10.4.3.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-3949542543211304">10.4.3.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e6230"></a><p class="title"><b>Example&nbsp;29.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlType</code>
                    - Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@XmlRootElement(name = "addNumbers", namespace = "http://server.fromjava/")</span>
<span class="Annotation">@XmlAccessorType(XmlAccessType.FIELD)</span>
<span class="Annotation">@XmlType(name = "addNumbers", namespace = "http://server.fromjava/", 
        propOrder = {"arg0", "arg1"})</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbers {

    <span class="Annotation">@XmlElement(name = "arg0", namespace = "")</span>
    <span class="ReservedWord">private</span> <span class="ReservedWord">int</span> arg0;
    <span class="Annotation">@XmlElement(name = "arg1", namespace = "")</span>
    <span class="ReservedWord">private</span> <span class="ReservedWord">int</span> arg1;

    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> getArg0() {
        <span class="ReservedWord">return</span> <span class="ReservedWord">this</span>.arg0;
    }

    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> setArg0(<span class="ReservedWord">int</span> arg0) {
        <span class="ReservedWord">this</span>.arg0 = arg0;
    }

    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> getArg1() {
        <span class="ReservedWord">return</span> <span class="ReservedWord">this</span>.arg1;
    }

    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> setArg1(<span class="ReservedWord">int</span> arg1) {
        <span class="ReservedWord">this</span>.arg1 = arg1;
    }
}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.4.4.&nbsp;@javax.xml.bind.annotation.XmlElement"><div class="titlepage"><div><div><h4 class="title" id="section-147120285802621">10.4.4.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlElement</code></h4></div></div></div><p>This annotation is used to map a property contained in a
            class to a local element in the XML Schema complex type to which
            the containing class is mapped.</p><div class="table"><a name="d0e6243"></a><p class="title"><b>Table&nbsp;23.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlElement</code>
                - Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.bind.annotation.XmlElement&#xA;                - Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">name</code></p></td><td><p>Defines the local name of the XML
                            element representing the property of a
                            JavaBean</p></td><td><p>"<code class="literal">##default</code>" - the
                            element name is derived from the JavaBean property
                            name.</p></td></tr><tr><td><p><code class="literal">namespace</code></p></td><td><p>Defines the namespace of the XML
                            element representing the property of a
                            JavaBean</p></td><td><p>"<code class="literal">##default</code>" - the
                            namespace of the containing class</p></td></tr><tr><td><p><code class="literal">nillable</code></p></td><td><p>Not generated by JAX-WS</p></td><td><p></p></td></tr><tr><td><p><code class="literal">type</code></p></td><td><p>Not generated by JAX-WS</p></td><td><p></p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.4.4.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-585474581494925">10.4.4.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> XmlElement {
    <span class="Comment">/**
     * Name of the XML Schema element.
     * &lt;p&gt; If the value is "##default", then element name is derived from
     * the
     * JavaBean property name.
     */</span>
    String name() <span class="ReservedWord">default</span> <span class="String">"##default"</span>;

    <span class="Comment">/**
     * Customize the element declaration to be nillable.
     * &lt;p&gt;If nillable() is true, then the JavaBean property is
     * mapped to a XML Schema nillable element declaration.
     */</span>
    <span class="ReservedWord">boolean</span> nillable() <span class="ReservedWord">default</span> false;

    <span class="Comment">/**
     * Customize the element declaration to be required.
     * &lt;p&gt;If required() is true, then Javabean property is mapped to
     * an XML schema element declaration with minOccurs="1".
     * maxOccurs is "1" for a single valued property and "unbounded"
     * for a multivalued property.
     * &lt;p&gt;If required() is false, then the Javabean property is mapped
     * to XML Schema element declaration with minOccurs="0".
     * maxOccurs is "1" for a single valued property and "unbounded"
     * for a multivalued property.
     */</span>

    <span class="ReservedWord">boolean</span> required() <span class="ReservedWord">default</span> false;

    <span class="Comment">/**
     * XML target namespace of the XML Schema element.
     * &lt;p/&gt;
     * If the value is "##default", then the namespace is determined
     * as follows:
     * &lt;ol&gt;
     * &lt;li&gt;
     * If the enclosing package has {@link XmlSchema} annotation,
     * and its {@link XmlSchema#elementFormDefault() elementFormDefault}
     * is {@link XmlNsForm#QUALIFIED QUALIFIED}, then the namespace of
     * the enclosing class.
     * &lt;p/&gt;
     * &lt;li&gt;
     * Otherwise &amp;#39;&amp;#39; (which produces unqualified element in the 
     * default
     * namespace.
     * &lt;/ol&gt;
     */</span>
    String namespace() <span class="ReservedWord">default</span> <span class="String">"##default"</span>;

    <span class="Comment">/**
     * Default value of this element.
     * &lt;p/&gt;
     * &lt;p/&gt;
     * The &lt;pre&gt;'\u0000'&lt;/pre&gt; value specified as a default of this 
     * annotation element
     * is used as a poor-man's substitute for null to allow implementations
     * to recognize the 'no default value' state.
     */</span>
    String defaultValue() <span class="ReservedWord">default</span> <span class="String">"\u0000"</span>;

    <span class="Comment">/**
     * The Java class being referenced.
     */</span>
    Class type() <span class="ReservedWord">default</span> DEFAULT.<span class="ReservedWord">class</span>;

    <span class="Comment">/**
     * Used in {@link XmlElement#type()} to
     * signal that the type be inferred from the signature
     * of the property.
     */</span>
    <span class="ReservedWord">static</span> <span class="ReservedWord">final</span> <span class="ReservedWord">class</span> DEFAULT {
    }
}</pre></div></div><div class="section" title="10.4.4.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-3035378616552507">10.4.4.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e6318"></a><p class="title"><b>Example&nbsp;30.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlElement</code>
                    - Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@XmlRootElement(name = "addNumbers", namespace = "http://server.fromjava/")</span>
<span class="Annotation">@XmlAccessorType(XmlAccessType.FIELD)</span>
<span class="Annotation">@XmlType(name = "addNumbers", namespace = "http://server.fromjava/", 
        propOrder = {"arg0", "arg1"})</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbers {

    <span class="Annotation">@XmlElement(name = "arg0", namespace = "")</span>
    <span class="ReservedWord">private</span> <span class="ReservedWord">int</span> arg0;
    <span class="Annotation">@XmlElement(name = "arg1", namespace = "")</span>
    <span class="ReservedWord">private</span> <span class="ReservedWord">int</span> arg1;

    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> getArg0() {
        <span class="ReservedWord">return</span> <span class="ReservedWord">this</span>.arg0;
    }

    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> setArg0(<span class="ReservedWord">int</span> arg0) {
        <span class="ReservedWord">this</span>.arg0 = arg0;
    }

    <span class="ReservedWord">public</span> <span class="ReservedWord">int</span> getArg1() {
        <span class="ReservedWord">return</span> <span class="ReservedWord">this</span>.arg1;
    }

    <span class="ReservedWord">public</span> <span class="ReservedWord">void</span> setArg1(<span class="ReservedWord">int</span> arg1) {
        <span class="ReservedWord">this</span>.arg1 = arg1;
    }
}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.4.5.&nbsp;@javax.xml.bind.annotation.XmlSeeAlso"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-bind-annotation-xmlseealso">10.4.5.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlSeeAlso</code></h4></div></div></div><p>Instructs JAXB to also bind other classes when binding this
            class.</p><div class="table"><a name="d0e6331"></a><p class="title"><b>Table&nbsp;24.&nbsp;<code class="literal">@javax.xml.bind.annotation.XmlSeeAlso</code>
                - Description of Properties</b></p><div class="table-contents"><table summary="@javax.xml.bind.annotation.XmlSeeAlso&#xA;                - Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">value</code></p></td><td><p>Other classes that JAXB can use when
                            binding this class</p></td><td><p>{}</p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.4.5.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-4562047312606827">10.4.5.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Comment">/**
 * Instructs JAXB to also bind other classes when binding this class.
 * &lt;p/&gt;
 * Java makes it impractical/impossible to list all sub-classes of
 * a given class. This often gets in a way of JAXB users, as it JAXB
 * cannot automatically list up the classes that need to be known
 * to {@link JAXBContext}.
 * &lt;p/&gt;
 * For example, with the following class definitions:
 * &lt;p/&gt;
 * &lt;pre&gt;
 * class Animal {}
 * class Dog extends Animal {}
 * class Cat extends Animal {}
 * &lt;/pre&gt;
 * &lt;p/&gt;
 * The user would be required to create {@link JAXBContext} as
 * &lt;tt&gt;JAXBContext.newInstance(Dog.class,Cat.class)&lt;/tt&gt;
 * (&lt;tt&gt;Animal&lt;/tt&gt; will be automatically picked up since &lt;tt&gt;Dog&lt;/tt&gt;
 * and &lt;tt&gt;Cat&lt;/tt&gt; refers to it.)
 * &lt;p/&gt;
 * {@link XmlSeeAlso} annotation would allow you to write:
 * &lt;pre&gt;
 * &amp;#64;XmlSeeAlso({Dog.class,Cat.class})
 * class Animal {}
 * class Dog extends Animal {}
 * class Cat extends Animal {}
 * &lt;/pre&gt;
 * &lt;p/&gt;
 * This would allow you to do &lt;tt&gt;JAXBContext.newInstance(Animal.class)
 * &lt;/tt&gt;.
 * By the help of this annotation, JAXB implementations will be able to
 * correctly bind &lt;tt&gt;Dog&lt;/tt&gt; and &lt;tt&gt;Cat&lt;/tt&gt;.
 *
 * @author Kohsuke Kawaguchi
 * @since JAXB2.1
 */</span>
<span class="Annotation">@Target({ElementType.TYPE})</span>
<span class="Annotation">@Retention(RUNTIME)</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> XmlSeeAlso {
    Class[] value();
}</pre></div></div></div></div><div class="section" title="10.5.&nbsp;JSR 250 (Common Annotations) Annotations"><div class="titlepage"><div><div><h3 class="title" id="jsr-250-common-annotations">10.5.&nbsp;JSR 250 (Common Annotations) Annotations</h3></div></div></div><p>The following annotations are being documented because JAX-WS
        endpoints use them for resource injection, and as lifecycle methods.
        Please refer to sections 5.2.1 and 5.3 of the <a class="link" href="http://www.jcp.org/en/jsr/detail?id=224" target="_top">JAX-WS 2.0</a>
        specification for resource injection, and lifecycle management. For
        more information on these and other common annotations please refer to
        the <a class="link" href="http://www.jcp.org/en/jsr/detail?id=250" target="_top">JSR
        250: <span class="emphasis"><em>Common Annotations for the Java TM Platform</em></span>
        </a>.</p><div class="section" title="10.5.1.&nbsp;@javax.annotation.Resource"><div class="titlepage"><div><div><h4 class="title" id="javax-xml-bind-annotation-xmlrootelement-outline1">10.5.1.&nbsp;<code class="literal">@javax.annotation.Resource</code></h4></div></div></div><p>This annotation is used to mark a WebServiceContext resource
            that is needed by a web service. It is applied to a field or a
            method for JAX-WS endpoints. The container will inject an instance
            of the WebServiceContext resource into the endpoint implementation
            when it is initialized.</p><div class="table"><a name="d0e6386"></a><p class="title"><b>Table&nbsp;25.&nbsp;<code class="literal">@javax.annotation.Resource</code> -
                Description of Properties</b></p><div class="table-contents"><table summary="@javax.annotation.Resource -&#xA;                Description of Properties" border="1"><colgroup><col width="16%"><col width="54%"><col width="30%"></colgroup><thead><tr><th>Property</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><p><code class="literal">type</code></p></td><td><p>Java type of the
                            resource</p></td><td><p>For field annotations, the default is
                            the type of the field. For method annotations, the
                            default is the type of the JavaBeans
                            property.</p></td></tr></tbody></table></div></div><br class="table-break"><div class="section" title="10.5.1.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-26090909275792">10.5.1.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD})</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> Resource {

    <span class="Comment">// ...</span>

    <span class="Comment">/**
     * The Java type of the resource.  For field annotations,
     * the default is the type of the field.  For method annotations,
     * the default is the type of the JavaBeans property.
     * For class annotations, there is no default and this must be
     * specified.
     */</span>
    Class type() <span class="ReservedWord">default</span> java.lang.Object.<span class="ReservedWord">class</span>;
}</pre></div></div><div class="section" title="10.5.1.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-3989686945211064">10.5.1.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e6424"></a><p class="title"><b>Example&nbsp;31.&nbsp;<code class="literal">@javax.annotation.Resource</code> -
                    Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebService</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> HelloImpl {
    <span class="Annotation">@Resource</span>
    <span class="ReservedWord">private</span> WebServiceContext context;

    <span class="ReservedWord">public</span> String echoHello(String name) {
        <span class="Comment">// ...</span>
    }
}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.5.2.&nbsp;@javax.annotation.PostConstruct"><div class="titlepage"><div><div><h4 class="title" id="javax-annotation-postconstruct">10.5.2.&nbsp;<code class="literal">@javax.annotation.PostConstruct</code></h4></div></div></div><p>This annotation is used on a method that needs to be
            executed after dependency injection is done to perform any
            initialization. This method MUST be invoked before the class is
            put into service.</p><div class="section" title="10.5.2.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-944222438955486">10.5.2.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Comment">/**
 * The PostConstruct annotation is used on a method that needs to be 
 * executed
 * after dependency injection is done to perform any initialization. This
 * method MUST be invoked before the class is put into service. This
 * annotation MUST be supported on all classes that support dependency
 * injection. The method annotated with PostConstruct MUST be invoked even
 * if the class does not request any resources to be injected. Only one
 * method can be annotated with this annotation. The method on which the
 * PostConstruct annotation is applied MUST fulfill all of the following
 * criteria -
 * - The method MUST NOT have any parameters except in the case of EJB
 * interceptors   in which case it takes an InvocationC	ontext object as
 * defined by the EJB   specification.
 * - The return type of the method MUST be void.
 * - The method MUST NOT throw a checked exception.
 * - The method on which PostConstruct is applied MAY be public, protected,
 * package private or private.
 * - The method MUST NOT be static except for the application client.
 * - The method MAY be final.
 * - If the method throws an unchecked exception the class MUST NOT be 
 * put into
 * service except in the case of EJBs where the EJB can handle exceptions
 * and
 * even   recover from them.
 *
 * @see javax.annotation.PreDestroy
 * @see javax.annotation.Resource
 * @since Common Annotations 1.0
 */</span>
<span class="Annotation">@Documented</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target(ElementType.METHOD)</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> PostConstruct {
}</pre></div></div><div class="section" title="10.5.2.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-76012616986007">10.5.2.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e6446"></a><p class="title"><b>Example&nbsp;32.&nbsp;<code class="literal">@javax.annotation.PostConstruct</code>
                    - Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebService</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> HelloImpl {
    <span class="Annotation">@PostConstruct</span>
    <span class="ReservedWord">private</span> <span class="ReservedWord">void</span> init() {
        <span class="Comment">// ...</span>
    }

    <span class="ReservedWord">public</span> String echoHello(String name) {
        <span class="Comment">// ...</span>
    }
}</pre></div></div><br class="example-break"></div></div><div class="section" title="10.5.3.&nbsp;@javax.annotation.PreDestroy"><div class="titlepage"><div><div><h4 class="title" id="section-930833968571058">10.5.3.&nbsp;<code class="literal">@javax.annotation.PreDestroy</code></h4></div></div></div><p>The PreDestroy annotation is used on methods as a callback
            notification to signal that the instance is in the process of
            being removed by the container. The method annotated with
            PreDestroy is typically used to release resources that it has been
            holding.</p><div class="section" title="10.5.3.1.&nbsp;Annotation Type Definition"><div class="titlepage"><div><div><h5 class="title" id="section-916789883737631">10.5.3.1.&nbsp;Annotation Type Definition</h5></div></div></div><div class="informalexample"><pre class="programlisting"><span class="Comment">/**
 * The PreDestroy annotation is used on methods as a callback 
 * notification to
 * signal that the instance is in the process of being removed by the
 * container. The method annotated with PreDestroy is typically used to
 * release resources that it has been holding. This annotation MUST be
 * supported by all container managed objects that support PostConstruct
 * except the application client container in Java EE 5. The method on 
 * which
 * the PreDestroy annotation is applied MUST fulfill all of the following
 * criteria -
 * - The method MUST NOT have any parameters except in the case of EJB
 * interceptors in which case it takes an InvocationContext object as 
 * defined
 * by the EJB specification.
 * - The return type of the method MUST be void.
 * - The method MUST NOT throw a checked exception.
 * - The method on which PreDestroy is applied MAY be public, protected,
 * package private or private.
 * - The method MUST NOT be static.
 * - The method MAY be final.
 * - If the method throws an unchecked exception it is ignored except in 
 * the
 * case of EJBs where the EJB can handle exceptions.
 *
 * @see javax.annotation.PostConstruct
 * @see javax.annotation.Resource
 * @since Common Annotations 1.0
 */</span>

<span class="Annotation">@Documented</span>
<span class="Annotation">@Retention(RetentionPolicy.RUNTIME)</span>
<span class="Annotation">@Target(ElementType.METHOD)</span>
<span class="ReservedWord">public</span> <span class="Annotation">@interface</span> PreDestroy {
}</pre></div></div><div class="section" title="10.5.3.2.&nbsp;Examples"><div class="titlepage"><div><div><h5 class="title" id="section-9258638457952977">10.5.3.2.&nbsp;Examples</h5></div></div></div><div class="example"><a name="d0e6469"></a><p class="title"><b>Example&nbsp;33.&nbsp;<code class="literal">@javax.annotation.PreDestroy</code> -
                    Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Annotation">@WebService</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> HelloImpl {
    <span class="ReservedWord">public</span> String echoHello(String name) {
        <span class="Comment">// ...</span>
    }

    <span class="Annotation">@PreDestroy</span>
    <span class="ReservedWord">private</span> <span class="ReservedWord">void</span> release() {
        <span class="Comment">// ...</span>
    }
}</pre></div></div><br class="example-break"></div></div></div></div><div lang="en" class="section" title="11.&nbsp;Why WS-Addressing?"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-why-ws-addressing">11.&nbsp;Why WS-Addressing?</h2></div></div></div><div class="section" title="11.1.&nbsp;What is WS-Addressing?"><div class="titlepage"><div><div><h3 class="title" id="what-is-ws-addressing">11.1.&nbsp;What is WS-Addressing?</h3></div></div></div><p><a class="link" href="http://www.w3.org/2002/ws/addr/" target="_top">Web Services
        Addressing</a> provides transport-neutral mechanisms to address Web
        services and messages. The transport-neutrality is achieved by
        normalizing the information typically shared between transport
        protocols and messaging systems.&nbsp;To serve this purpose, WS-Addressing
        defines two new constructs, <span class="bold"><strong>Message Addressing
        Properties</strong></span> (MAPs) and <span class="bold"><strong>Endpoint
        Reference</strong></span> (EPR), that normalize the information independent
        of any particular transport or messaging system. MAPs convey
        end-to-end message characteristics including addressing for source and
        destination endpoints as well as message identity that allows uniform
        addressing of messages independent of the underlying transport. EPR
        convey the information needed to address a Web service
        endpoint.</p><p>The subsequent sections explain the different use cases served
        by WS-Addressing.</p><div class="section" title="11.1.1.&nbsp;Transport Neutrality"><div class="titlepage"><div><div><h4 class="title" id="transport-neutrality">11.1.1.&nbsp;Transport Neutrality</h4></div></div></div><p>This section describes how a message can be sent to a Web
            service endpoint in transport neutral manner.</p><div class="example"><a name="d0e6500"></a><p class="title"><b>Example&nbsp;34.&nbsp;SOAP 1.2 message, without WS-Addressing, sent over
                HTTP</b></p><div class="example-contents"><div class="programlistingco"><pre class="programlisting">POST /fabrikam/Purchasing HTTP 1.1/POST                    <span class="co" id=""><img src="icons/callouts/1.png" alt="(1)"></span>
Host: example.com
SOAPAction: http://example.com/fabrikam/SubmitPO

<span class="ReservedWord">&lt;S:Envelope</span>                                                <span class="co" id=""><img src="icons/callouts/2.png" alt="(2)"></span>
        <span class="Identifier">xmlns:S</span>=<span class="String">"http://www.w3.org/2003/05/soap-envelope"</span>
        <span class="Identifier">xmlns:wombat</span>=<span class="String">"http://wombat.org/"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;S:Header&gt;</span>
        <span class="ReservedWord">&lt;wombat:MessageID&gt;</span>
            uuid:e197db59-0982-4c9c-9702-4234d204f7f4
        <span class="ReservedWord">&lt;/wombat:MessageID&gt;</span>
    <span class="ReservedWord">&lt;/S:Header&gt;</span>
    <span class="ReservedWord">&lt;S:Body&gt;</span>
        ...
    <span class="ReservedWord">&lt;/S:Body&gt;</span>
<span class="ReservedWord">&lt;/S:Envelope&gt;</span></pre><div class="calloutlist"><table border="0" summary="Callout list"><tr><td width="5%" valign="top" align="left"><p><img src="icons/callouts/1.png" alt="1" border="0"></p></td><td valign="top" align="left"><p>HTTP transport headers.</p></td></tr><tr><td width="5%" valign="top" align="left"><p><img src="icons/callouts/2.png" alt="2" border="0"></p></td><td valign="top" align="left"><p>SOAP message in HTTP body.</p></td></tr></table></div></div><p>The host (<code class="literal">example.com</code>), the dispatch
                method (<code class="literal">POST</code>) and the URL to dispatch to
                (<code class="literal">/fabrikam/Purchasing</code>) are in the HTTP
                transport headers. The actual message and implied meaning (for
                example payload's <code class="literal">QName</code> or
                <code class="literal">SOAPAction</code>) is defined by the messaging
                system (<code class="literal">SOAP</code>) or transport protocol
                (<code class="literal">HTTP</code>). If the message is to be sent over
                an alternate transport, such as SMTP, then the information
                conveyed in HTTP transport headers need to be mapped to SMTP
                specific headers. On the server side, to dispatch
                successfully, a Web service stack has to gather the
                information from the SMTP (as opposed to HTTP) headers and the
                SOAP message.</p></div></div><br class="example-break"><p>Also in the above message, there is no standard header to
            establish the identity of a message. In this case,
            <code class="literal">MessageID</code> header defined in the namespace URI
            bound to <code class="literal">wombat</code> prefix is used but is
            application specific and is thus not re-usable.</p><p>WS-Addressing introduce Message Addressing Properties that
            collectively augment a message to normalize this
            information.</p><div class="example"><a name="d0e6551"></a><p class="title"><b>Example&nbsp;35.&nbsp;SOAP 1.2 message, with WS-Addressing, sent over
                HTTP</b></p><div class="example-contents"><div class="programlistingco"><pre class="programlisting">POST /fabrikam/Purchasing HTTP 1.1/POST                    <span class="co" id=""><img src="icons/callouts/1.png" alt="(1)"></span>
Host: example.com
SOAPAction: http://example.com/fabrikam/SubmitPO

<span class="ReservedWord">&lt;S:Envelope</span>                                                <span class="co" id=""><img src="icons/callouts/2.png" alt="(2)"></span>
        <span class="Identifier">xmlns:S</span>=<span class="String">"http://www.w3.org/2003/05/soap-envelope"</span>
        <span class="bold"><strong>xmlns:wsa="http://www.w3.org/2005/08/addressing/"</strong></span>&gt;
    <span class="ReservedWord">&lt;S:Header&gt;</span>
        <span class="bold"><strong>&lt;wsa:MessageID&gt;</strong></span>                                    <span class="co" id=""><img src="icons/callouts/3.png" alt="(3)"></span><span class="bold"><strong>
            uuid:e197db59-0982-4c9c-9702-4234d204f7f4
        &lt;/wsa:MessageID&gt;
        &lt;wsa:To&gt;
            http://example.com/fabrikam/Purchasing
        &lt;/wsa:To&gt;
        &lt;wsa:Action&gt;
            http://example.com/fabrikam/SubmitPO
        &lt;/wsa:Action&gt;</strong></span>
    <span class="ReservedWord">&lt;/S:Header&gt;</span>
    <span class="ReservedWord">&lt;S:Body&gt;</span>
        ...
    <span class="ReservedWord">&lt;/S:Body&gt;</span>
<span class="ReservedWord">&lt;/S:Envelope&gt;</span></pre><div class="calloutlist"><table border="0" summary="Callout list"><tr><td width="5%" valign="top" align="left"><p><img src="icons/callouts/1.png" alt="1" border="0"></p></td><td valign="top" align="left"><p>HTTP transport headers.</p></td></tr><tr><td width="5%" valign="top" align="left"><p><img src="icons/callouts/2.png" alt="2" border="0"></p></td><td valign="top" align="left"><p>SOAP message in HTTP body.</p></td></tr><tr><td width="5%" valign="top" align="left"><p><img src="icons/callouts/3.png" alt="3" border="0"></p></td><td valign="top" align="left"><p>Binding of Message Addressing Properties to
                            SOAP 1.2 message.</p></td></tr></table></div></div><p>For example, <code class="literal">wsa:MessageID</code> is a
                binding of an abstract property that defines an absolute URI
                that uniquely identifies the message,
                <code class="literal">wsa:To</code> is binding of an abstract absolute
                URI representing the address of the intended receiver of this
                message and <code class="literal">wsa:Action</code> is binding of an
                abstract absolute IRI that uniquely identifies the semantics
                implied by this message. All the information earlier shared
                between transport protocols and messaging systems is now
                normalized into a uniform format that can be processed
                independent of transport or application.</p><p>If the exactly same message is to be sent/received using
                a different transport, for example asynchronously over SMTP,
                then the value of <code class="literal">wsa:To</code> header could be
                changed to <code class="literal">mailto:purchasing@example.com</code>.
                The updated <code class="literal">wsa:To</code> header looks
                like:</p><pre class="programlisting"><span class="ReservedWord">&lt;wsa:To&gt;</span>
    <span class="bold"><strong>mailto:purchasing@example.com</strong></span>
<span class="ReservedWord">&lt;/wsa:To&gt;</span></pre><p>On the server side, Web services stack can gather all
                the information from the SOAP message and then dispatch it
                correctly.</p></div></div><br class="example-break"></div><div class="section" title="11.1.2.&nbsp;Stateful Web service"><div class="titlepage"><div><div><h4 class="title" id="stateful-web-service">11.1.2.&nbsp;Stateful Web service</h4></div></div></div><p>Web services are usually stateless, i.e. the service
            endpoint receives a request and responds back without saving any
            processing state in between different requests. However making Web
            services stateful enables to share multiple instances of service
            endpoints. For example, consider a stateful Bank Web service. The
            client (say bank customer) can obtain a bank EPR, with relevant
            state information stored as reference parameters, and invoke a
            method on that EPR to do a series of banking operations. On the
            service endpoint, whenever a request is received, the reference
            parameters from the EPR are available as first-class SOAP headers
            allowing the endpoint to restore the state.</p><p>JAX-WS RI 2.2.7 enables <a class="link" href="http://jax-ws.java.net/nonav/jax-ws-21-ea2/docs/users-guide-stateful-webservice" target="_top">stateful
            Web services</a>&nbsp;to be annotated with
            <code class="literal">com.sun.xml.ws.developer.Stateful</code>
            annotation.</p></div><div class="section" title="11.1.3.&nbsp;Simple and Complex MEPs"><div class="titlepage"><div><div><h4 class="title" id="simple-and-complex-meps">11.1.3.&nbsp;Simple and Complex MEPs</h4></div></div></div><p>WS-Addressing defines standard <a class="link" href="http://www.w3.org/TR/2006/REC-ws-addr-core-20060509/#abstractmaps" target="_top">Message
            Addressing Properties</a> (MAPs) to support simple and complex
            message patterns. The SOAP Binding defines a mapping of these MAPs
            to SOAP headers and convey end-to-end message characteristics
            including addressing for source and destination endpoints as well
            as message identity. For example <code class="literal">destination</code>
            MAP represents an absolute IRI representing the address of the
            intended receiver of the message and is mapped to a SOAP header
            with <code class="literal">wsa:To</code> element name. <code class="literal">reply
            endpoint</code> represents an endpoint reference for the
            intended receiver for replies to this message and is mapped to a
            SOAP header with <code class="literal">wsa:ReplyTo</code> element name.&nbsp; In
            addition, WSDL Binding, also defines requirement on the presence
            of these MAPs for standard Message Exchange Patterns (MEPs) such
            as <a class="link" href="http://www.w3.org/TR/wsdl#_request-response" target="_top">request/response</a>
            and <a class="link" href="http://www.w3.org/TR/wsdl#_one-way" target="_top">one-way</a>.</p><p>Using these MAPs, complex MEPs can be created. For
            example:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p><span class="bold"><strong>Asynchronous MEP</strong></span>:
                    Using <code class="literal">reply endpoint</code> MAP, an
                    asynchronous transport may be specified for a synchronous
                    request. For example, a client application might send a
                    request over HTTP and ask to receive the response through
                    SMTP.</p></li><li class="listitem"><p><span class="bold"><strong>Conversation MEP</strong></span>:
                    Using <code class="literal">relationship</code> MAP, that defines
                    the relationship between two messages, a conversational
                    MEP can be defined by correlating multiple
                    request/response MEPs. For example a client sending a
                    request to service endpoint receives a response with
                    <code class="literal">wsa:RelatesTo</code> MAP. The service endpoint
                    may optionally include <code class="literal">wsa:MessageID</code> in
                    the response. This MAP can then be included by the client
                    in <code class="literal">wsa:RelatesTo</code> MAP in next request to
                    the service endpoint there by starting a
                    conversation.</p></li><li class="listitem"><p><span class="bold"><strong>Distributed MEP</strong></span>:
                    Using <code class="literal">reply endpoint</code> and <code class="literal">fault
                    endpoint</code> MAP, a different transport/address can
                    be specified for receiving normal and fault responses
                    respectively.</p></li></ol></div></div><div class="section" title="11.1.4.&nbsp;Composability with other WS-* specifications"><div class="titlepage"><div><div><h4 class="title" id="composability-with-other-ws-specifications">11.1.4.&nbsp;Composability with other WS-* specifications</h4></div></div></div><p>There are several Web services specification (commonly known
            as <a class="link" href="http://en.wikipedia.org/wiki/WS-*" target="_top">WS-*
            specs</a>) that make use of the abstract properties defined by
            WS-Addressing. For example <a class="link" href="http://en.wikipedia.org/wiki/WS-MetadataExchange" target="_top">WS-Metadata
            Exchange</a> define a bootstrap mechanism for retrieving
            metadata before the business message exchange can take place. This
            mechanism involve sending a <a class="link" href="http://www.w3.org/Submission/WS-Transfer/" target="_top">WS-Transfer</a>
            request for the retrieval of a resource's representation. A
            typical request message looks like:</p><div class="programlistingco"><pre class="programlisting"><span class="ReservedWord">&lt;s11:Envelope</span>                                              <span class="co" id=""><img src="icons/callouts/1.png" alt="(1)"></span>
        <span class="Identifier">xmlns:s11</span>=<span class="String">"http://schemas.xmlsoap.org/soap/envelope/"</span>
        <span class="bold"><strong>xmlns:wsa="http://www.w3.org/2005/08/addressing"</strong></span>&gt;  <span class="co" id=""><img src="icons/callouts/2.png" alt="(2)"></span>
    <span class="ReservedWord">&lt;s11:Header&gt;</span>
        <span class="ReservedWord">&lt;wsa:Action&gt;</span>                                       <span class="co" id=""><img src="icons/callouts/3.png" alt="(3)"></span>
            <span class="bold"><strong>http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</strong></span>
        <span class="ReservedWord">&lt;/wsa:Action&gt;</span>
        <span class="ReservedWord">&lt;wsa:To&gt;</span>http://example.org/metadata<span class="ReservedWord">&lt;/wsa10:To&gt;</span>
        <span class="ReservedWord">&lt;wsa:ReplyTo&gt;</span>
            <span class="ReservedWord">&lt;wsa:Address&gt;</span>http://www.w3.org/2005/08/addressing/anonymous
            <span class="ReservedWord">&lt;/wsa10:Address&gt;</span>
        <span class="ReservedWord">&lt;/wsa:ReplyTo&gt;</span>
        <span class="ReservedWord">&lt;wsa:MessageID&gt;</span>
            uuid: 68da6b24-7fa1-4da2-8a06-e615bfa3d2d0
        <span class="ReservedWord">&lt;/wsa:MessageID&gt;</span>
    <span class="ReservedWord">&lt;/s11:Header&gt;</span>
    <span class="ReservedWord">&lt;s11:Body/&gt;</span>
<span class="ReservedWord">&lt;/s11:Envelope&gt;</span></pre><div class="calloutlist"><table border="0" summary="Callout list"><tr><td width="5%" valign="top" align="left"><p><img src="icons/callouts/1.png" alt="1" border="0"></p></td><td valign="top" align="left"><p>SOAP request message to retrieve metadata about
                        a Web service endpoint.</p></td></tr><tr><td width="5%" valign="top" align="left"><p><img src="icons/callouts/2.png" alt="2" border="0"></p></td><td valign="top" align="left"><p>WS-Addressing namespace URI bound to
                        "<code class="literal">wsa</code>" prefix.</p></td></tr><tr><td width="5%" valign="top" align="left"><p><img src="icons/callouts/3.png" alt="3" border="0"></p></td><td valign="top" align="left"><p>The standard WS-Addressing MAPs used to convey
                        the semantics (<code class="literal">wsa:Action</code>),
                        receiver (<code class="literal">wsa:To</code>) of the message,
                        intended receiver of reply
                        (<code class="literal">wsa:ReplyTo</code>) message and identity
                        (<code class="literal">wsa:MessageID</code>) information of the
                        message</p></td></tr></table></div></div><p>This message has an empty SOAP Body and relies completely
            upon standard MAPs to convey all the information. Similarly, a
            WS-Metadata Exchange response message with metadata looks
            like:</p><div class="programlistingco"><pre class="programlisting"><span class="ReservedWord">&lt;s11:Envelope</span>
        <span class="Identifier">xmlns:s11</span>=<span class="String">"http://schemas.xmlsoap.org/soap/envelope/"</span>
        <span class="bold"><strong>xmlns:wsa="http://www.w3.org/2005/08/addressing"</strong></span>&gt;
    <span class="ReservedWord">&lt;s11:Header&gt;</span>
        <span class="ReservedWord">&lt;wsa:Action&gt;</span>                                       <span class="co" id=""><img src="icons/callouts/1.png" alt="(1)"></span>
            <span class="bold"><strong>http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse</strong></span>
        <span class="ReservedWord">&lt;/wsa:Action&gt;</span>
        <span class="ReservedWord">&lt;wsa:RelatesTo&gt;</span>
            uuid: 68da6b24-7fa1-4da2-8a06-e615bfa3d2d0
        <span class="ReservedWord">&lt;/wsa:RelatesTo&gt;</span>
    <span class="ReservedWord">&lt;/s11:Header&gt;</span>
    <span class="ReservedWord">&lt;s11:Body/&gt;</span>                                            <span class="co" id=""><img src="icons/callouts/2.png" alt="(2)"></span>
    ...
    <span class="ReservedWord">&lt;s11:Body/&gt;</span>
<span class="ReservedWord">&lt;/s11:Envelope&gt;</span></pre><div class="calloutlist"><table border="0" summary="Callout list"><tr><td width="5%" valign="top" align="left"><p><img src="icons/callouts/1.png" alt="1" border="0"></p></td><td valign="top" align="left"><p>The standard WS-Addressing MAPs used to convey
                        the semantics (<code class="literal">wsa:Action</code>) of the
                        response message and relationship
                        (<code class="literal">wsa:RelatesTo</code>) to the request
                        message.</p></td></tr><tr><td width="5%" valign="top" align="left"><p><img src="icons/callouts/2.png" alt="2" border="0"></p></td><td valign="top" align="left"><p>Abbreviated SOAP Body for simplicity which
                        otherwise would contain the MEX response.</p></td></tr></table></div></div><p><a class="link" href="http://en.wikipedia.org/wiki/WS-ReliableMessaging" target="_top">WS-Reliable
            Messaging</a> describes a protocol that allows messages to be
            delivered reliably between distributed applications in the
            presence of software component, system or network failures. This
            specification defines protocol messages that must be exchanged
            between client and service endpoint, before the business message
            exchange, in order to deliver the messages reliably. For example,
            RM Source sends <code class="literal">&lt;CreateSequence&gt;</code> request
            message to RM Destination to create an outbound sequence. The
            message looks like:</p><div class="programlistingco"><pre class="programlisting"><span class="ReservedWord">&lt;s11:Envelope</span>
        <span class="Identifier">xmlns:s11</span>=<span class="String">"http://schemas.xmlsoap.org/soap/envelope/"</span>
        <span class="bold"><strong>xmlns:wsa=" http://www.w3.org/2005/08/addressing"</strong></span>
        xmlns:wsrm=" http://schemas.xmlsoap.org/ws/2005/02/rm"&gt;
    <span class="ReservedWord">&lt;s11:Body&gt;</span>                                             <span class="co" id=""><img src="icons/callouts/1.png" alt="(1)"></span>
        <span class="ReservedWord">&lt;wsrm:CreateSequence&gt;</span>
            <span class="bold"><strong>&lt;wsrm:AcksTo&gt;</strong></span>
                <span class="ReservedWord">&lt;wsa:Address&gt;</span>
                    http://www.w3.org/2005/08/addressing/anonymous
                <span class="ReservedWord">&lt;/wsa:Address&gt;</span>
            <span class="bold"><strong>&lt;/wsrm:AcksTo&gt;</strong></span>
        <span class="ReservedWord">&lt;/wsrm:CreateSequence&gt;</span>
    <span class="ReservedWord">&lt;/s11:Body&gt;</span>
<span class="ReservedWord">&lt;/s11:Envelope&gt;</span></pre><div class="calloutlist"><table border="0" summary="Callout list"><tr><td width="5%" valign="top" align="left"><p><img src="icons/callouts/1.png" alt="1" border="0"></p></td><td valign="top" align="left"><p>SOAP Body of the request message.</p></td></tr></table></div></div><p>The Body contains an element, <code class="literal">wsrm:AcksTo</code>
            (of the type Endpoint Reference), that specifies the endpoint
            reference to which
            <code class="literal">&lt;SequenceAcknowledgement&gt;</code> messages and
            faults related to sequence creation are sent.</p><p>WS-Secure Conversation, WS-Trust, WS-Policy and other
            similar specifications use the constructs defined by WS-Addressing
            as building blocks.</p></div></div><div class="section" title="11.2.&nbsp;WS-Addressing Versions"><div class="titlepage"><div><div><h3 class="title" id="ws-addressing-versions">11.2.&nbsp;WS-Addressing Versions</h3></div></div></div><p>There are two prominent versions of WS-Addressing that are
        commonly used:&nbsp;</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><a class="link" href="http://www.w3.org/2002/ws/addr/" target="_top">W3C
                WS-Addressing</a></p></li><li class="listitem"><p><a class="link" href="http://www.w3.org/Submission/ws-addressing/" target="_top">Member
                Submission WS-Addressing</a></p></li></ul></div><p>Sun, IBM, BEA, Microsoft and SAP co-authored and submitted a
        WS-Addressing specification to W3C in August 2004. W3C chartered a new
        Working Group with a mission to produce a <a class="link" href="http://www.w3.org/2005/10/Process-20051014/tr.html#RecsW3C" target="_top">W3C
        Recommendation</a> for WS-Addressing by refining the submitted
        specification. The original specification submitted to W3C is referred
        as "Member Submission WS-Addressing" or "Submission WS-Addressing".
        The term <a class="link" href="http://www.w3.org/2005/10/Process-20051014/submission.html#Submission" target="_top">Member
        Submission</a> is defined by W3C.</p><p>The WG was <a class="link" href="http://www.w3.org/2006/10/ws-addr-charter.html#deliverables" target="_top">chartered</a>
        to deliver a W3C Recommendation for WS-Addressing <a class="link" href="http://www.w3.org/TR/ws-addr-core" target="_top">Core</a>, <a class="link" href="http://www.w3.org/TR/ws-addr-soap" target="_top">SOAP Binding</a>
        (mapping abstract properties defined in Core to SOAP 1.1 and 1.2) and
        <a class="link" href="http://www.w3.org/TR/ws-addr-wsdl" target="_top">WSDL
        Binding</a> (mechanisms to define property values in WSDL 1.1 and
        WSDL 2.0 service descriptions) specification. This separate between
        Core/Bindings is common methodology where Core is relevant to
        application developers and Binding (both SOAP and WSDL) is relevant
        for Web service stack implementers. This collective set of
        specifications is referred as "W3C WS-Addressing".</p><p>JAX-WS RI supports both versions
        out-of-the-box. Check <a class="link" href="http://jax-ws.java.net/nonav/jax-ws-21-ea2/docs/users-guide-overview" target="_top">Users
        Guide</a> on how to enable either of the versions on a service
        endpoint <a class="link" href="http://jax-ws.java.net/nonav/jax-ws-21-ea2/docs/users-guide-ws-addressing#Addressing_annotations" target="_top">starting
        from Java</a> or <a class="link" href="http://jax-ws.java.net/nonav/jax-ws-21-ea2/docs/users-guide-ws-addressing#Starting_from_WSDL" target="_top">starting
        from WSDL</a>.</p></div></div><div lang="en" class="section" title="12.&nbsp;WS-Addressing"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-ws-addressing">12.&nbsp;WS-Addressing</h2></div></div></div><div class="section" title="12.1.&nbsp;WS-Addressing in JAX-WS RI"><div class="titlepage"><div><div><h3 class="title" id="ws-addressing-in">12.1.&nbsp;WS-Addressing in JAX-WS RI</h3></div></div></div><p><a class="link" href="http://www.w3.org/2002/ws/addr/" target="_top">Web Services
        Addressing</a> provides transport-neutral mechanisms to address Web
        services and messages. JAX-WS 2.2 specification requires support for
        W3C <a class="link" href="http://www.w3.org/TR/ws-addr-core" target="_top">Core</a>,
        <a class="link" href="http://www.w3.org/TR/ws-addr-soap" target="_top">SOAP
        Binding</a> and <a class="link" href="http://www.w3.org/TR/2007/REC-ws-addr-metadata-20070904" target="_top">Addressing
        1.0 - Metadata</a> specifications and defines standard API to
        enable/disable W3C WS-Addressing on the client and service endpoint.
        In addition to that, JAX-WS RI also supports <a class="link" href="http://www.w3.org/Submission/ws-addressing/" target="_top">Member
        Submission</a> version of WS-Addressing. The member submission
        version is supported in an implementation specific way.&nbsp; For
        compatility with JAX-WS 2.1 behavior, JAX-WS RI 2.2.7 also
        supports wsdls conforming to <a class="link" href="http://www.w3.org/TR/ws-addr-wsdl" target="_top">WSDL Binding</a>
        specification. The subsequent sections describe how the two
        WS-Addressing versions can be enabled/disabled on client and server
        side .</p></div><div class="section" title="12.2.&nbsp;Why WS-Addressing?"><div class="titlepage"><div><div><h3 class="title" id="why-ws-addressing">12.2.&nbsp;Why WS-Addressing?</h3></div></div></div><p>This <a class="xref" href="ch03.html#users-guide-why-ws-addressing" title="11.&nbsp;Why WS-Addressing?">Why WS-Addressing?</a> explains what is WS-Addressing and why it
        is required.</p></div><div class="section" title="12.3.&nbsp;Describing WS-Addressing in WSDL"><div class="titlepage"><div><div><h3 class="title" id="describing-ws-addressing-in-wsdl">12.3.&nbsp;Describing WS-Addressing in WSDL</h3></div></div></div><p>WS Addressing 1.0- Metadata defines standard ways to describe
        message addressing properties like Action, Destination in wsdl and
        also indicate the use of Addressing in wsdl. WS-Addressing Metadata
        specification replaces the previous <a class="link" href="http://www.w3.org/TR/2006/CR-ws-addr-wsdl-20060529/" target="_top">Web
        Services Addressing 1.0 - WSDL Binding</a> specification in
        candidate recommendation earlier. If you are still using wsdls
        conforming to WS Addressing 1.0 - WSDL Binding specification, skip to
        the next section. Still you may want to update your wsdls to use in
        standard ways defined by the W3C recommended Addressing 1.0 - Metadata
        specification for better interoperability. Also,&nbsp; There is no standard
        mechanism to describe Member Submission version support in the WSDL
        and some implementaions have used WS-Policy to indicate the support of
        member submission version and JAX-WS RI understands
        such assertion.</p><div class="section" title="12.3.1.&nbsp;WS-Addressing 1.0 - Metadata"><div class="titlepage"><div><div><h4 class="title" id="ws-addressing-1-0-metadata">12.3.1.&nbsp;WS-Addressing 1.0 - Metadata</h4></div></div></div><p><a class="link" href="http://www.w3.org/TR/2007/REC-ws-addr-metadata-20070904/" target="_top">Addressing
            1.0 - Metadata</a> specification uses Web Services Policy
            Framework (<a class="link" href="http://www.w3.org/TR/2007/REC-ws-policy-20070904" target="_top">WS
            Policy 1.5</a>) and Web Services Policy - Attachment [ <a class="link" href="http://www.w3.org/TR/2007/REC-ws-policy-attach-20070904" target="_top">WS
            Policy 1.5 - Attachment</a>] specifications to express the
            support of Web Services Addressing 1.0. A new policy assertion
            <code class="literal">&lt;wsam:Addressing&gt;</code> is defined to express
            the support of Addressing. The <code class="literal">wsam:Addressing</code>
            policy assertion applies to the endpoint policy subject and may be
            attached to <code class="literal">wsdl11:port</code> or
            <code class="literal">wsdl11:binding</code>.</p><p>Indicating the requirement of WS-Addressing: When
            </p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;wsam:Addressing&gt;</span></pre></div><p>is present in a Policy alternative, one is
            required to use WS-Addressing to communicate with the
            subject.</p><p>Indicating the support of WS-Addressing: </p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;wsam:Addressing</span> <span class="Identifier">wsp:Optional</span>=<span class="String">"true"</span><span class="ReservedWord">&gt;</span></pre></div><p>can be used to indicate support for
            WS-Addressing but does not require the use of it. In these cases,
            there are no restrictions about the use of WS-Adressing.</p><p>In certain cases, the endpoint can lay some restrictions to
            indicate the messages it can accept with WS-Addressing. Nested
            asertions can be used to restrict the use of response endpoint
            inside the <code class="literal">&lt;wsam:Addressing&gt;</code>
            assertion.</p><p>Requiring the use of Non-Anonymous response
            endpoints:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;wsam:Addressing&gt;</span>
    <span class="ReservedWord">&lt;wsp:Policy&gt;</span>
        <span class="ReservedWord">&lt;wsam:NonAnonymousResponses/&gt;</span>
    <span class="ReservedWord">&lt;/wsp:Policy&gt;</span>
<span class="ReservedWord">&lt;/wsam:Addressing&gt;</span></pre></div><p>can be used to indicate that the subject requires
            WS-Addressing and requires the use of non-anonymous response EPRs.
            In this case, the response endpoint in the request messages will
            have to use something other than the anonymous URI as the value of
            address. This is typically used when the response needs to be sent
            to a third entity other than the client and service and the
            response is sent to the non-anonyous URI through a new connection
            Requiring the use of Anonymous response endpoints:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;wsam:Addressing&gt;</span>
    <span class="ReservedWord">&lt;wsp:Policy&gt;</span>
        <span class="ReservedWord">&lt;wsam:AnonymousResponses/&gt;</span>
    <span class="ReservedWord">&lt;/wsp:Policy&gt;</span>
<span class="ReservedWord">&lt;/wsam:Addressing&gt;</span></pre></div><p>can be used to indicate that the subject requires
            WS-Addressing and requires the use of anonymous responses. In this
            case, the endpoint requires request messages to use response
            endpoint EPRs that contain the anonymous URI
            ("<code class="literal">http://www.w3.org/2005/08/addressing/anonymous</code>")
            or None URI
            ("<code class="literal">http://www.w3.org/2005/08/addressing/none</code>")
            as the value of address.</p></div><div class="section" title="12.3.2.&nbsp;WS-Addressing WSDL Binding"><div class="titlepage"><div><div><h4 class="title" id="ws-addressing-wsdl-binding">12.3.2.&nbsp;WS-Addressing WSDL Binding</h4></div></div></div><p>W3C WS-Addressing WSDL Binding defines an extensibility
            element, <a class="link" href="http://www.w3.org/TR/2006/CR-ws-addr-wsdl-20060529/#uaee" target="_top">wsaw:UsingAddressing</a>,
            that can be used to indicate that an endpoint conforms to the
            WS-Addressing specification. JAX-WS RI generates
            this extension element in the WSDL if W3C WS-Addressing is enabled
            on the server-side. On the client side, the RI recognizes this
            extension element and enforce the rules defined by the W3C
            specification. This extensibility element may be augmented with
            <code class="literal">wsdl:required</code> attribute to indicate whether
            WS-Addressing is required (true) or not (false).</p><p>W3C WS-Addressing WSDL Binding defines
            <code class="literal">wsaw:Anonymous</code> element which when used in
            conjunction with <code class="literal">wsaw:UsingAddressing</code> define
            assertions regarding a requirement or a constraint in the use of
            anonymous URI in EPRs sent to the endpoint. The WSDL Binding
            defines three distinct values: <code class="literal">optional</code>,
            <code class="literal">required</code> and <code class="literal">prohibited</code> to
            express the assertion. The default value of
            <code class="literal">wsaw:Anonymous</code> (equivalent to not present) is
            <code class="literal">optional</code>. An operation with
            <code class="literal">required</code> <code class="literal">wsaw:Anonymous</code>
            value is shown below:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;wsaw:UsingAddressing</span> <span class="Identifier">wsdl:required</span>=<span class="String">"true"</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;soap:binding</span> <span class="Identifier">transport</span>=<span class="String">"http://schemas.xmlsoap.org/soap/http"</span>
        <span class="Identifier">style</span>=<span class="String">"document"</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;operation</span> <span class="Identifier">name</span>=<span class="String">"addNumbers"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;soap:operation</span> <span class="Identifier">soapAction</span>=<span class="String">""</span><span class="ReservedWord">/&gt;</span>
    
    ...
    
    <span class="ReservedWord">&lt;wsaw:Anonymous&gt;</span>required<span class="ReservedWord">&lt;/wsaw:Anonymous&gt;</span>
<span class="ReservedWord">&lt;/operation&gt;</span>
<span class="ReservedWord">&lt;soap:binding&gt;</span></pre></div><p>In this case, a message received at the endpoint, for this
            operation, with a non-anonymous ReplyTo or FaultTo EPR will result
            in a fault message returned back to the client with
            <code class="literal">wsa:OnlyAnonymousAddressSupported</code> fault code.
            There is no such equivalent feature in Member Submission
            WS-Addressing.</p></div></div><div class="section" title="12.4.&nbsp;Configuring Addressing on Endpoint"><div class="titlepage"><div><div><h3 class="title" id="configuring-addressing-on-endpoint">12.4.&nbsp;Configuring Addressing on Endpoint</h3></div></div></div><p>This section describes how W3C and Member Submission
        WS-Addressing can be enabled/disabled on the server-side.</p><div class="section" title="12.4.1.&nbsp;Starting from WSDL"><div class="titlepage"><div><div><h4 class="title" id="starting-from-wsdl">12.4.1.&nbsp;Starting from WSDL</h4></div></div></div><p>Starting from WSDL, If the wsdl contains the above described
            metadata to indicate use addressing at endpoint scope, Addressing
            is enabled on the server-side.&nbsp; See&nbsp; <a class="xref" href="ch03.html#describing-ws-addressing-in-wsdl" title="12.3.&nbsp;Describing WS-Addressing in WSDL">Describing WS-Addressing in WSDL</a> section for more details.</p></div><div class="section" title="12.4.2.&nbsp;Starting from Java"><div class="titlepage"><div><div><h4 class="title" id="starting-from-java-1">12.4.2.&nbsp;Starting from Java</h4></div></div></div><p>This section describes how WS-Addressing can be
            enabled/disabled if you develop an endpoint starting from a Java
            SEI.</p><p>By default, WS-Addressing is disabled on an endpoint
            starting from Java. If that is the expected behavior, then nothing
            else needs to be done. In that case any WS-Addressing headers
            received at the endpoint are treated like SOAP headers targeted
            for the appliaction and are ignored.</p><div class="section" title="12.4.2.1.&nbsp;Addressing annotations"><div class="titlepage"><div><div><h5 class="title" id="addressing-annotations">12.4.2.1.&nbsp;Addressing annotations</h5></div></div></div><p>If WS-Addressing support needs to be enabled on an
                endpoint, then along with
                <code class="literal">javax.jws.WebService</code> annotation,
                <code class="literal">javax.xml.ws.soap.Addressing</code> annotation
                need to be specified for enabling W3C WS-Addressing. If Member
                Submission WS-Addressing needs to be enabled then&nbsp;
                <code class="literal">com.sun.xml.ws.developer.MemberSubmissionAddressing</code>
                annotation needs to be specified on the service endpoint. For
                example, the service endpoint in&nbsp;
                <code class="literal">fromjava-wsaddressing</code> sample looks
                like:</p><div class="informalexample"><pre class="programlisting"><span class="Annotation">@javax.xml.ws.soap.Addressing</span>
<span class="Annotation">@javax.jws.WebService</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl {

    <span class="Comment">// ...</span>

}</pre></div><p>To enable, Member Submission WS-Addressing, the SEI
                definition needs to be changed to:</p><div class="informalexample"><pre class="programlisting"><span class="Annotation">@com.sun.xml.ws.developer.MemberSubmissionAddressing</span>
<span class="Annotation">@javax.jws.WebService</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">class</span> AddNumbersImpl {

    <span class="Comment">// ...</span>

}</pre></div><p>Once WS-Addressing support is enabled on a service
                endpoint, then:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>In the generated WSDL, corresponding metadata as
                        described in section Describing Addressing in WSDL is
                        generated.</p></li><li class="listitem"><p>All WS-Addressing headers are understood, i.e.
                        if any WS-Addressing header is received with a
                        <code class="literal">mustUnderstand="1"</code>, then a
                        mustUnderstand fault is not thrown back.</p></li><li class="listitem"><p>All WS-Addressing headers received at the
                        endpoint are checked for correct syntax, for example
                        an error is returned back if
                        <code class="literal">wsa:ReplyTo</code> header does not match
                        the infoset defined in the corresponding
                        specification.</p></li><li class="listitem"><p>If any WS-Addressing header received at the
                        endpoint is not of correct cardinality, then an error
                        is returned back to the client.</p></li><li class="listitem"><p>If <code class="literal">wsa:Action</code> header value
                        does not match with that expected for that operation,
                        then an error is returned back to the client.</p></li><li class="listitem"><p>Any response message sent back to the client
                        contains the required WS-Addressing headers.&nbsp;</p></li></ul></div></div><div class="section" title="12.4.2.2.&nbsp;Is Addressing Optional or Required ?"><div class="titlepage"><div><div><h5 class="title" id="is-addressing-optional-or-required">12.4.2.2.&nbsp;Is Addressing Optional or Required ?</h5></div></div></div><p>Both <code class="literal">javax.xml.ws.soap.Addressing</code> and
                <code class="literal">com.sun.xml.ws.developer.MemberSubmissionAddressing</code>
                annotations take two optional Boolean parameters,
                <code class="literal">enabled</code> (default true) and
                <code class="literal">required</code> (default false). If
                <code class="literal">required</code> is specified true, then
                WS-Addressing rules are enforced. Otherwise the inbound
                message is inspected to find out if WS-A is engaged and then
                the rules are enforced. See <a class="xref" href="ch03.html#when-is-ws-addressing-engaged" title="12.6.&nbsp;When is WS-Addressing engaged?">When is WS-Addressing engaged?</a> section for more details on
                enforcement during runtime.</p><p>For example, to enforce Member Submission WS-Addressing
                rules on the server side, the above code sample will change
                to:</p><div class="informalexample"><pre class="programlisting"><span class="Annotation">@com.sun.xml.ws.developer.MemberSubmissionAddressing(enabled = true,
        required = true)</span>
<span class="Annotation">@javax.jws.WebServicepublic</span>
<span class="ReservedWord">class</span> AddNumbersImpl {

    <span class="Comment">// ...</span>

}</pre></div></div></div></div><div class="section" title="12.5.&nbsp;On the client side"><div class="titlepage"><div><div><h3 class="title" id="on-the-client-side">12.5.&nbsp;On the client side</h3></div></div></div><p>This section describes how WS-Addressing can be enabled/disabled
        on the client-side. JAX-WS RI follows the standard
        extensibility elements in WSDL to enable WS-Addressing support on the
        client side. In addition, it also allows the client to instruct
        JAX-WS RI to disable WS-Addressing processing. The
        assumption is that in this case the client has it's own WS-Addressing
        processing module. For example, a Dispatch-based client in MESSAGE
        mode may be used to perform non-anonymous ReplyTo/FaultTo
        processing.</p><div class="section" title="12.5.1.&nbsp;Implicit behavior"><div class="titlepage"><div><div><h4 class="title" id="implicit-behavior">12.5.1.&nbsp;Implicit behavior</h4></div></div></div><p>As defined in <a class="xref" href="ch03.html#describing-ws-addressing-in-wsdl" title="12.3.&nbsp;Describing WS-Addressing in WSDL">Describing WS-Addressing in WSDL</a>, If the WSDL contains metadata about
            the support or requirement of WS-Addressing,
            JAX-WS RI runtime enables Addressing feature on
            the client-side.</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Generates <code class="literal">Action</code>,
                    <code class="literal">To</code>, <code class="literal">MessageID</code> and
                    anonymous <code class="literal">ReplyTo</code> headers on the
                    outbound request.</p></li><li class="listitem"><p>Any WS-Addressing headers received on the client are
                    processed.</p></li></ul></div><p>There is no standard extensibility element for Member
            Submission WS-Addressing and so there is no implicit behavior
            defined. It can only be explicitly enabled as described in the
            next section.&nbsp;</p></div><div class="section" title="12.5.2.&nbsp;Explicit enabling"><div class="titlepage"><div><div><h4 class="title" id="explicit-enabling">12.5.2.&nbsp;Explicit enabling</h4></div></div></div><p>If a WSDL does not contain WS-Addressing standard
            extensibility element, then either W3C WS-Addressing or Member
            Submission WS-Addressing can be explicitly enabled using
            <code class="literal">createDispatch</code> and <code class="literal">getPort</code>
            methods on <code class="literal">javax.xml.ws.Service</code>. The following
            new APIs are added in JAX-WS 2.1:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><div class="informalexample"><pre class="programlisting">&lt;T&gt; Dispatch&lt;T&gt; createDispatch(javax.xml.namespace.QName portName, java.lang.Class&lt;T&gt; type, Service.Mode mode, WebServiceFeature... features)</pre></div></li><li class="listitem"><div class="informalexample"><pre class="programlisting">Dispatch&lt;java.lang.Object&gt; createDispatch(javax.xml.namespace.QName portName, javax.xml.bind.JAXBContext context, Service.Mode mode, WebServiceFeature... features)</pre></div></li><li class="listitem"><div class="informalexample"><pre class="programlisting">&lt;T&gt; T getPort(java.lang.Class&lt;T&gt; serviceEndpointInterface, WebServiceFeature... features)</pre></div></li><li class="listitem"><div class="informalexample"><pre class="programlisting">&lt;T&gt; T getPort(javax.xml.namespace.QName portName, java.lang.Class&lt;T&gt; serviceEndpointInterface, WebServiceFeature... features)</pre></div></li></ul></div><p>Each method is a variation of an already existing method in
            JAX-WS 2.0. The only addition is an extra var-arg
            <code class="literal">javax.xml.ws.WebServiceFeature</code> parameter. A
            <code class="literal">WebServiceFeature</code> is a new class introduced in
            JAX-WS 2.1 specification used to represent a feature that can be
            enabled or disabled for a Web service.</p><p>The JAX-WS 2.1 specification defines
            <code class="literal">javax.xml.ws.soap.AddressingFeature</code> to enable
            W3C WS-Addressing on the client side. In addition, the
            JAX-WS RI also defines
            <code class="literal">com.sun.xml.ws.developer.MemberSubmissionAddressingFeature</code>
            to enable Member Submission WS-Addressing on the client
            side.</p><p>For example in <code class="literal">fromjava-wsaddressing</code>
            example, in order to enable W3C WS-Addressing on a proxy,
            <span class="command"><strong>wsimport</strong></span> is used to generate the
            <code class="literal">AddNumbersImplService</code> class. Then a port can be
            obtained using the <code class="literal">getAddNumbersImplPort</code> method
            and passing an instance of
            <code class="literal">javax.xml.ws.AddressingFeature</code>. The code looks
            like:</p><div class="informalexample"><pre class="programlisting">new AddNumbersImplService().getAddNumbersImplPort(new javax.xml.ws.AddressingFeature());</pre></div><p>Similarly, a <code class="literal">Dispatch</code> instance with
            Member Submission WS-Addressing can be created as:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">new</span> AddNumbersImplService().createDispatch(
        <span class="ReservedWord">new</span> QName(<span class="String">"http://server.fromjava_wsaddressing/"</span>, 
                <span class="String">"AddNumbersImplPort"</span>),
        SOAPMessage.<span class="ReservedWord">class</span>, 
        Service.Mode.MESSAGE,
        <span class="ReservedWord">new</span> com.sun.xml.ws.developer.MemberSubmissionAddressingFeature());</pre></div><p><span class="bold"><strong>Feature Parameters</strong></span></p><p>Both <code class="literal">javax.xml.ws.soap.AddressingFeature</code>
            and
            <code class="literal">com.sun.xml.ws.developer.MemberSubmissionAddressingFeature</code>
            take two optional Boolean parameters, <code class="literal">enabled</code>
            (default true) and <code class="literal">required</code> (default false). If
            enabled, all WS-Addressing headers are generated for an outbound
            message. If <code class="literal">required</code> is specified true, then
            WS-Addressing rules are enforced for inbound message. Otherwise
            the inbound message is inspected to find out if WS-A is engaged
            and then the rules are enforced.</p><p>For example, to enforce Member Submission WS-Addressing
            rules on the client side, the above code sample will change
            to:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">new</span> AddNumbersImplService().getAddNumbersImplPort(<span class="ReservedWord">new</span> com.sun.xml
        .ws.developer.MemberSubmissionAddressingFeature(true, true));</pre></div></div><div class="section" title="12.5.3.&nbsp;Explicit disabling"><div class="titlepage"><div><div><h4 class="title" id="explicit-disabling">12.5.3.&nbsp;Explicit disabling</h4></div></div></div><p>A client may like to instruct JAX-WS RI to
            disable WS-Addressing processing. The assumption is that in this
            case the client has it's own WS-Addressing processing module. For
            example, a Dispatch-based client in MESSAGE mode may be used to
            perform non-anonymous ReplyTo/FaultTo processing.</p><p>WS-Addressing processing can be explicitly disabled using
            one of new methods added to JAX-WS 2.1 specification as defined in
            Section 3.2. For example, W3C WS-Addressing processing can be
            disabled using the following code:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">new</span> AddNumbersImplService().getAddNumbersImplPort(<span class="ReservedWord">new</span> javax.xml.ws.AddressingFeature(false));</pre></div></div></div><div class="section" title="12.6.&nbsp;When is WS-Addressing engaged?"><div class="titlepage"><div><div><h3 class="title" id="when-is-ws-addressing-engaged">12.6.&nbsp;When is WS-Addressing engaged?</h3></div></div></div><p>W3C WS-Addressing SOAP Binding <a class="link" href="http://www.w3.org/TR/2006/REC-ws-addr-soap-20060509/#conformance" target="_top">defines</a>
        that if a receiver processes a message containing a
        <code class="literal">wsa:Action</code> header, then SOAP Binding is engaged,
        and the rules of the specification are enforced. In
        JAX-WS RI, if WS-Addressing is explicitly disabled
        then the RI does not follow the rules of engagement. However if
        WS-Addressing is either implicitly or explicitly enabled then
        JAX-WS RI engages WS-Addressing based upon the
        presence of <code class="literal">wsa:Action</code> header.
        JAX-WS RI follows same rule for Member Submission
        version as well.</p><p>In effect, if an endpoint advertises WS-Addressing is required
        in the WSDL and a client does not send any WS-Addressing header then
        no WS-Addressing fault is returned back to the client. However if the
        client send <code class="literal">wsa:Action</code> header then the endpoint
        will enforce all the rules of the specification. For example, if the
        <code class="literal">wsa:MessageID</code> header is missing for a
        request/response MEP then a fault with appropriate code and sub-code
        is thrown back to the client.</p></div><div class="section" title="12.7.&nbsp;Associating Action with an operation"><div class="titlepage"><div><div><h3 class="title" id="associating-action-with-an-operation">12.7.&nbsp;Associating Action with an operation</h3></div></div></div><div class="section" title="12.7.1.&nbsp;Implicit Action"><div class="titlepage"><div><div><h4 class="title" id="implicit-action">12.7.1.&nbsp;Implicit Action</h4></div></div></div><p>In most common cases, an implicit Action association, as
            defined by <a class="link" href="http://www.w3.org/TR/2007/REC-ws-addr-metadata-20070904/#actioninwsdl" target="_top">W3C
            WS-Addressing 1.0 - Metadata</a> and <a class="link" href="http://www.w3.org/Submission/ws-addressing/#_Toc77464327" target="_top">Member
            Submission</a>, will be sufficient. For such cases, only using
            the correct annotation to enable Addressing is required. The
            client looking at such a WSDL will send the implicit
            <code class="literal">wsa:Action</code> header. If only Addressing is
            enabled by using the appropriate annotation at the SEI,&nbsp;</p></div><div class="section" title="12.7.2.&nbsp;Explicit Action"><div class="titlepage"><div><div><h4 class="title" id="explicit-action">12.7.2.&nbsp;Explicit Action</h4></div></div></div><p>This section describes how an explicit Action Message
            Addressing Property can be associated with an operation in the
            SEI.</p><p>W3C WS-Addressing <a class="link" href="http://www.w3.org/TR/2007/REC-ws-addr-metadata-20070904/#actioninwsdl" target="_top">W3C
            WS-Addressing 1.0 - Metadata</a> and <a class="link" href="http://www.w3.org/Submission/ws-addressing/#_Toc77464325" target="_top">Member
            Submission WS-Addressing</a> define mechanisms to associate
            Action Message Addressing Property with an operation. JAX-WS 2.1
            defines <code class="literal">javax.xml.ws.Action</code> and
            <code class="literal">javax.xml.ws.FaultAction</code> annotations to
            explicitly associate an Action with <code class="literal">input</code>,
            <code class="literal">output</code>, and <code class="literal">fault</code> messages
            of the mapped WSDL operation. For example, one of the methods in
            the <code class="literal">fromjava-wsaddressing</code> sample looks
            like:</p><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Action(input = "http://example.com/input3", output = "http://example.com/output3",
        fault = {@FaultAction(className = AddNumbersException.class,
        value = "http://example.com/fault3")})</span>
<span class="ReservedWord">public</span> <span class="ReservedWord">int</span> addNumbers3(<span class="ReservedWord">int</span> number1, <span class="ReservedWord">int</span> number2) <span class="ReservedWord">throws</span> AddNumbersException {

    <span class="Comment">// ...</span>

}</pre></div><p>The generated WSDL fragment looks like:</p><div class="informalexample"><pre class="programlisting"><span class="ReservedWord">&lt;operation</span> <span class="Identifier">name</span>=<span class="String">"addNumbers3"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;input</span> <span class="Identifier">wsam:Action</span>=<span class="String">"http://example.com/input3"</span>
            <span class="Identifier">message</span>=<span class="String">"tns:addNumbers3"</span><span class="ReservedWord">/&gt;</span>
    <span class="ReservedWord">&lt;output</span> <span class="Identifier">wsam:Action</span>=<span class="String">"http://example.com/output3"</span>
            <span class="Identifier">message</span>=<span class="String">"tns:addNumbers3Response"</span><span class="ReservedWord">/&gt;</span>
    <span class="ReservedWord">&lt;fault</span> <span class="Identifier">message</span>=<span class="String">"tns:AddNumbersException"</span> <span class="Identifier">name</span>=<span class="String">"AddNumbersException"</span>
            <span class="Identifier">wsam:Action</span>=<span class="String">"http://example.com/fault3"</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;/operation&gt;</span></pre></div><p>where <code class="literal">wsam</code> is bound to W3C WS-Addressing
            1.0 - Metadata namespace or Member Submission namespace depending
            upon the annotation used to enable Addressing.&nbsp;</p></div></div></div><div lang="en" class="section" title="13.&nbsp;Stateful Webservice"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-stateful-webservice">13.&nbsp;Stateful Webservice</h2></div></div></div><div class="section" title="13.1.&nbsp;Introduction"><div class="titlepage"><div><div><h3 class="title" id="introduction-1">13.1.&nbsp;Introduction</h3></div></div></div><p>JAX-WS RI has a vendor extension that allows
        developers to bring back object state to the web service world.
        Normally, JAX-WS RI only creates one instance of a
        service class, and have it serve all incoming requests concurrently.
        This makes it essentially impossible to use instance fields of the
        service class for any meaningful purpose.</p><p>Because of this, people end up coding like C, in anti-OO
        fashion. Either that or you end up with writing boiler-plate code to
        dispatch a request to the right instance of your real domain
        object.</p><p>The stateful web service support in JAX-WS RI
        resolves this problem by having JAX-WS RI maintain
        multiple instances of a service. By using <a class="xref" href="ch03.html#users-guide-ws-addressing" title="12.&nbsp;WS-Addressing">WS-Addressing</a> behind
        the scene, it provides a standard-based on-the-wire protocol and
        easy-to-use programming model.</p></div><div class="section" title="13.2.&nbsp;Usage"><div class="titlepage"><div><div><h3 class="title" id="usage">13.2.&nbsp;Usage</h3></div></div></div><p>Application service implementation classes (or providers) who'd
        like to use the stateful web service support must declare
        <code class="code">@Stateful</code> annotation on a class. It should also have a
        <span class="bold"><strong>public static</strong></span> method/field that takes
        <code class="code">StatefulWebServiceManager</code>.</p><div class="informalexample"><pre class="programlisting"><span class="Annotation">@Stateful</span>
<span class="Annotation">@WebService</span>
<span class="Annotation">@Addressing</span>
<span class="ReservedWord">class</span> BankAccount {
    
    <span class="ReservedWord">protected</span> <span class="ReservedWord">final</span> <span class="ReservedWord">int</span> id;
    <span class="ReservedWord">private</span> <span class="ReservedWord">int</span> balance;

    BankAccount(<span class="ReservedWord">int</span> id) {
        <span class="ReservedWord">this</span>.id = id;
    }

    <span class="Annotation">@WebMethod</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">synchronized</span> <span class="ReservedWord">void</span> deposit(<span class="ReservedWord">int</span> amount) {
        balance += amount;
    }

    <span class="Comment">// either via a public static field</span>

    <span class="ReservedWord">public</span> <span class="ReservedWord">static</span> StatefulWebServiceManager&lt;BankAccount&gt; manager;

    <span class="Comment">// ... or  via a public static method (the method name could be </span>
    <span class="Comment">// anything)</span>

    <span class="ReservedWord">public</span> <span class="ReservedWord">static</span> <span class="ReservedWord">void</span> setManager(StatefulWebServiceManager&lt;BankAccount&gt; 
                                          manager) {
        <span class="Comment">// ...</span>
    }

}</pre></div><p>After your service is deployed but before you receive a first
        request, the resource injection occurs on the field or the
        method.</p><p>A stateful web service class does not need to have a default
        constructor. In fact, most of the time you want to define a
        constructor that takes some arguments, so that each instance carries
        certain state (as illustrated in the above example).</p><p>Each instance of a stateful web service class is identified by
        an unique <code class="literal">EndpointReference</code>. Your application
        creates an instance of a class, then you'll have
        JAX-WS RI assign this unique EPR for the instance as
        follows:</p><div class="informalexample"><pre class="programlisting"><span class="Annotation">@WebService</span>
<span class="ReservedWord">class</span> Bank { <span class="Comment">// this is ordinary stateless service</span>

    <span class="Annotation">@WebMethod</span>
    <span class="ReservedWord">public</span> <span class="ReservedWord">synchronized</span> W3CEndpointReference login(<span class="ReservedWord">int</span> accountId, 
                                                   <span class="ReservedWord">int</span> pin) {
        <span class="ReservedWord">if</span> (!checkPin(pin))
            <span class="ReservedWord">throw</span> <span class="ReservedWord">new</span> AuthenticationFailedException(<span class="String">"invalid pin"</span>);
        BankAccount acc = <span class="ReservedWord">new</span> BankAccount(accountId);
        <span class="ReservedWord">return</span> BankAccount.manager.export(acc);
    }
    
}</pre></div><p>Typically you then pass this EPR to remote systems. When they
        send messages to this EPR, JAX-WS RI makes sure that
        the particular exported instance associated with that EPR will receive
        a service invocation.</p></div><div class="section" title="13.3.&nbsp;Things To Consider"><div class="titlepage"><div><div><h3 class="title" id="things-to-consider">13.3.&nbsp;Things To Consider</h3></div></div></div><p>When you no longer need to tie an instance to the EPR, use
        <code class="literal">unexport(Object)</code> so that the object can be GC-ed
        (or else you'll leak memory). You may choose to do so explicitly, or
        you can rely on the time out by using <code class="literal">setTimeout(long,
        Callback)</code>.</p><p><code class="literal">StatefulWebServiceManager</code> is thread-safe. It
        can be safely invoked from multiple threads concurrently.</p></div></div><div lang="en" class="section" title="14.&nbsp;Catalog"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-catalog">14.&nbsp;Catalog</h2></div></div></div><div class="section" title="14.1.&nbsp;Catalog Support"><div class="titlepage"><div><div><h3 class="title" id="section-529979392543239">14.1.&nbsp;Catalog Support</h3></div></div></div><p>Often times, such as for performance reason or your application
        specific needs, you have a need where you want to resolve the
        WSDL/Schema documents resolved from the copy of it you have either
        bundled with your client or server or just to resolve it not from
        where a WSDL/schema imports points to but rather from where you want
        it to be picked up.</p><div class="section" title="14.1.1.&nbsp;A Sample catalog file"><div class="titlepage"><div><div><h4 class="title" id="section-459374253706355">14.1.1.&nbsp;A Sample catalog file</h4></div></div></div><div class="example"><a name="d0e7410"></a><p class="title"><b>Example&nbsp;36.&nbsp;<code class="filename">jax-ws-catalog.xml</code></b></p><div class="example-contents"><pre class="programlisting">&lt;catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
        prefer=" system"&gt;
    
    ...

    &lt; system systemId=" http://foo.org/hello?wsdl" uri="HelloService.wsdl"/&gt;
&lt;/catalog&gt;</pre></div></div><br class="example-break"><div class="section" title="14.1.1.1.&nbsp;Location of the catalog file"><div class="titlepage"><div><div><h5 class="title" id="section-695398485401359">14.1.1.1.&nbsp;Location of the catalog file</h5></div></div></div><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>For <span class="command"><strong>wsimport</strong></span> command-line or
                        ant task </p><div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p>use <code class="option">-catalog</code> option to pass
                                    the catalog file. The name of the catalog file does
                                    not matter for <span class="command"><strong>wsimport</strong></span> tool but
                                    for consistency you may like to call it
                                    <code class="filename">jax-ws-catalog.xml</code></p></li><li class="listitem"><p>use </p><pre class="programlisting"><span class="ReservedWord">&lt;wsimport</span> <span class="Identifier">catalog</span>=<span class="String">"''&gt;</span></pre><p>or</p><pre class="programlisting">&lt;xmlcatalog ... /&gt;</pre><p>with
                                    <span class="command"><strong>wsimport</strong></span> ant task</p></li></ul></div></li><li class="listitem"><p>Client Runtime </p><div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p><code class="filename">META-INF/jax-ws-catalog.xml</code>
                                    picked up from classpath</p></li></ul></div></li><li class="listitem"><p>Lightweight HTTP server (j2se) based endpoints
                        </p><div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p><code class="filename">META-INF/jax-ws-catalog.xml</code>
                                    picked up from classpath</p></li></ul></div></li><li class="listitem"><p>Servlet based endpoints or JSR 109 based Web
                        Module </p><div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p><code class="filename">WEB-INF/jax-ws-catalog.xml</code></p></li></ul></div></li><li class="listitem"><p>JSR 109 based EJB Modules </p><div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p><code class="filename">META-INF/jax-ws-catalog.xml</code></p></li></ul></div></li></ul></div><p>For details on XML catalog see <a class="link" href="http://xml.apache.org/commons/components/resolver/resolver-article.html" target="_top">here</a>.</p></div></div></div></div><div lang="en" class="section" title="15.&nbsp;WAR File Packaging"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-war-file-packaging">15.&nbsp;WAR File Packaging</h2></div></div></div><div class="section" title="15.1.&nbsp;The WAR Contents"><div class="titlepage"><div><div><h3 class="title" id="section-5694250262578">15.1.&nbsp;The WAR Contents</h3></div></div></div><p>Typically, one creates the WAR file with a GUI development tool
        or with the <code class="literal">ant</code> <code class="literal">war</code> task from
        the generated artifacts from <span class="command"><strong>wsimport</strong></span>,
        <span class="command"><strong>wsgen</strong></span>, or <span class="command"><strong>apt</strong></span> tools.</p><p>For example, a sample WAR file starting from a WSDL file:</p><div class="table"><a name="d0e7515"></a><p class="title"><b>Table&nbsp;26.&nbsp;Files contained in WAR when starting from WSDL</b></p><div class="table-contents"><table summary="Files contained in WAR when starting from WSDL" border="1"><colgroup><col width="50%"><col width="50%"></colgroup><thead><tr><th>File</th><th>Description</th></tr></thead><tbody><tr><td><code class="code">WEB-INF/classes/hello/HelloIF.class</code></td><td><p>SEI</p></td></tr><tr><td><code class="code">WEB-INF/classes/hello/HelloImpl.class</code></td><td><p>Endpoint</p></td></tr><tr><td><code class="code">WEB-INF/sun-jaxws.xml</code></td><td><p>JAX-WS RI deployment
                        descriptor</p></td></tr><tr><td><code class="code">WEB-INF/web.xml</code></td><td><p>Web deployment descriptor</p></td></tr><tr><td><code class="code">WEB-INF/wsdl/HelloService.wsdl</code></td><td><p>WSDL</p></td></tr><tr><td><code class="code">WEB-INF/wsdl/schema.xsd</code></td><td><p>WSDL imports this Schema</p></td></tr></tbody></table></div></div><br class="table-break"></div><div class="section" title="15.2.&nbsp;The sun-jaxws.xml File"><div class="titlepage"><div><div><h3 class="title" id="the-sun-jaxws-xml-file">15.2.&nbsp;The <code class="literal">sun-jaxws.xml</code> File</h3></div></div></div><p>The <code class="literal">&lt;endpoints&gt;</code> element contain one or
        more <code class="literal">&lt;endpoint&gt;</code> elements. Each endpoint
        represents a port in the WSDL and it contains all information about
        <code class="literal">implementation</code> class, servlet
        <code class="literal">url-pattern</code>, <code class="literal">binding</code>,
        <code class="literal">WSDL</code>, <code class="literal">service</code>,
        <code class="literal">port</code> QNames. The following shows a
        <code class="literal">sun-jaxws.xml</code> file for a simple
        <code class="literal">HelloWorld</code> service.
        <code class="filename">sun-jaxws.xml</code> is the schema instance of <a class="link" href="sun-jaxws.xsd" target="_top">sun-jaxws.xsd</a>.</p><div class="informalexample"><pre class="programlisting"><span class="hl-directive" style="color: maroon">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="ReservedWord">&lt;endpoints</span> <span class="Identifier">xmlns</span>=<span class="String">"http://java.sun.com/xml/ns/jax-ws/ri/runtime"</span>
        <span class="Identifier">version</span>=<span class="String">"2.0"</span><span class="ReservedWord">&gt;</span>
    <span class="ReservedWord">&lt;endpoint</span> <span class="Identifier">name</span>=<span class="String">"MyHello"</span> <span class="Identifier">implementation</span>=<span class="String">"hello.HelloImpl"</span>
            <span class="Identifier">url-pattern</span>=<span class="String">"/hello"</span><span class="ReservedWord">/&gt;</span>
<span class="ReservedWord">&lt;/endpoints&gt;</span></pre></div><p>Endpoint can have the following attributes:</p><div class="table"><a name="d0e7617"></a><p class="title"><b>Table&nbsp;27.&nbsp;<code class="literal">sun-jaxws.xml</code> - Endpoint element
            attributes.</b></p><div class="table-contents"><table summary="sun-jaxws.xml - Endpoint element&#xA;            attributes." border="1"><colgroup><col width="33%"><col width="33%"><col width="34%"></colgroup><thead><tr><th><p>Attribute</p></th><th><p>Optional</p></th><th><p>Use</p></th></tr></thead><tbody><tr><td><code class="code">name </code></td><td><p>N</p></td><td><p>Name of the endpoint</p></td></tr><tr><td><code class="code">wsdl </code></td><td><p>Y</p></td><td><p>Primary wsdl file location in the WAR
                        file. For e.g.
                        <code class="filename">WEB-INF/wsdl/HelloService.wsdl</code>.
                        If this isn't specified, JAX-WS will create and
                        publish a new WSDL. When the service is developed from
                        Java, it is recommended to omit this
                        attribute.</p></td></tr><tr><td><code class="code">service </code></td><td><p>Y</p></td><td><p>QName of WSDL service. For e.g.
                        <code class="literal">{http://example.org/}HelloService</code>.
                        When the service is developed from Java, it is
                        recommended to omit this attribute.</p></td></tr><tr><td><code class="code">port </code></td><td><p>Y</p></td><td><p>QName of WSDL port. For e.g.
                        <code class="literal">{http://example.org/}HelloPort</code>.
                        When the service is developed from Java, it is
                        recommended to omit this attribute.</p></td></tr><tr><td><code class="code">implementation </code></td><td><p>N</p></td><td><p>Endpoint implementation class name. For
                        e.g: <code class="literal">hello.HelloImpl</code>. The class
                        should have a <code class="literal">@WebService</code>
                        annotation. Provider based implementation class should
                        have a <code class="literal">@WebServiceProvider</code>
                        annotation.</p></td></tr><tr><td><code class="code">url-pattern </code></td><td><p>N</p></td><td><p>Should match
                        <code class="literal">&lt;url-pattern&gt;</code> in
                        <code class="filename">web.xml</code></p></td></tr><tr><td><code class="code">binding </code></td><td><p>Y</p></td><td><p>Binding id defined in the JAX-WS API. The
                        possible values are:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><code class="literal">"http://schemas.xmlsoap.org/wsdl/soap/http"</code></p></li><li class="listitem"><p><code class="literal">"http://www.w3.org/2003/05/soap/bindings/HTTP/"</code></p></li></ul></div><p>If omitted, it is considered
                        <code class="literal">SOAP1.1</code> binding.</p></td></tr><tr><td><code class="code">enable-mtom </code></td><td><p>Y</p></td><td><p>Enables MTOM optimization.
                        <code class="literal">true</code> or <code class="literal">false</code>.
                        Default is <code class="literal">false</code>.</p></td></tr></tbody></table></div></div><br class="table-break"><p>Endpoint can have a optional <code class="literal">handler-chain</code>
        element:</p><div class="informalexample"><pre class="programlisting"><span class="hl-directive" style="color: maroon">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="ReservedWord">&lt;endpoints</span> <span class="Identifier">...&gt;</span>
    <span class="Identifier">&lt;endpoint</span> <span class="Identifier">...&gt;</span>
        <span class="Identifier">&lt;handler-chain&gt;</span>
            <span class="Identifier">&lt;handler-chain-name&gt;somename&lt;/handler-chain-name&gt;</span>
            <span class="Identifier">&lt;handler&gt;</span>
                <span class="Identifier">&lt;handler-name&gt;MyHandler&lt;/handler-name&gt;</span>
                <span class="Identifier">&lt;handler-class&gt;hello.MyHandler&lt;/handler-class&gt;</span>
            <span class="Identifier">&lt;/handler&gt;</span>
        <span class="Identifier">&lt;/handler-chain&gt;</span>
    <span class="Identifier">&lt;/endpoint&gt;</span>
<span class="Identifier">&lt;/endpoints&gt;</span></pre></div></div><div class="section" title="15.3.&nbsp;The web.xml File"><div class="titlepage"><div><div><h3 class="title" id="section-42577169574826">15.3.&nbsp;The <code class="literal">web.xml</code> File</h3></div></div></div><p>The following shows a <code class="literal">web.xml</code> file for a
        simple <code class="literal">HelloWorld</code> service. It specifies
        JAX-WS RI specific listener, servlet classes. These
        classes are
        <code class="literal">com.sun.ws.transport.http.servlet.WSServletContextListener</code>,
        and <code class="literal">com.sun.xml.ws.transport.http.servlet.WSServlet</code>
        is servlet</p><div class="informalexample"><pre class="programlisting"><span class="hl-directive" style="color: maroon">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="Comment">&lt;!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd"&gt;</span>
<span class="ReservedWord">&lt;web-app&gt;</span>
    <span class="ReservedWord">&lt;listener&gt;</span>
        <span class="ReservedWord">&lt;listener-class&gt;</span>
            com.sun.xml.ws.transport.http.servlet.WSServletContextListener
        <span class="ReservedWord">&lt;/listener-class&gt;</span>
    <span class="ReservedWord">&lt;/listener&gt;</span>
    <span class="ReservedWord">&lt;servlet&gt;</span>
        <span class="ReservedWord">&lt;servlet-name&gt;</span>hello<span class="ReservedWord">&lt;/servlet-name&gt;</span>
        <span class="ReservedWord">&lt;servlet-class&gt;</span>com.sun.xml.ws.transport.http.servlet.WSServlet
        <span class="ReservedWord">&lt;/servlet-class&gt;</span>
        <span class="ReservedWord">&lt;load-on-startup&gt;</span>1<span class="ReservedWord">&lt;/load-on-startup&gt;</span>
    <span class="ReservedWord">&lt;/servlet&gt;</span>
    <span class="ReservedWord">&lt;servlet-mapping&gt;</span>
        <span class="ReservedWord">&lt;servlet-name&gt;</span>hello<span class="ReservedWord">&lt;/servlet-name&gt;</span>
        <span class="ReservedWord">&lt;url-pattern&gt;</span>/hello<span class="ReservedWord">&lt;/url-pattern&gt;</span>
    <span class="ReservedWord">&lt;/servlet-mapping&gt;</span>
    <span class="ReservedWord">&lt;session-config&gt;</span>
        <span class="ReservedWord">&lt;session-timeout&gt;</span>60<span class="ReservedWord">&lt;/session-timeout&gt;</span>
    <span class="ReservedWord">&lt;/session-config&gt;</span>
<span class="ReservedWord">&lt;/web-app&gt;</span></pre></div><p>Remember these requirements when building a WAR:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>WSDL and auxiliary WSDL, Schema files should be packaged
                under <code class="filename">WEB-INF/wsdl</code> dir. It is recommended
                that they need not be packaged when the service is started
                from Java</p></li><li class="listitem"><p>WebService implementation class should contain a
                <code class="literal">@WebService</code> annotation. Provider based
                endpoints should have a <code class="literal">@WebServiceProvider</code>
                annotation.</p></li><li class="listitem"><p><code class="literal">wsdl</code>, <code class="literal">service</code>,
                <code class="literal">port</code> attributes are mandatory for
                <code class="literal">Provider</code> based endpoints and can be
                specified in the <code class="literal">@WebServiceProvider</code>
                annotation or deployment descriptor
                (<code class="filename">sun-jaxws.xml</code>).</p></li></ul></div></div></div><div lang="en" class="section" title="16.&nbsp;Interoperability"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-interoperability">16.&nbsp;Interoperability</h2></div></div></div><p>JAX-WS RI 2.2.7 provides a comprehensive interoperability
    platform to develop web services solutions. Here are the key
    interoperability features:</p><div class="section" title="16.1.&nbsp;WSDL and Message Level Interoperability"><div class="titlepage"><div><div><h3 class="title" id="section-4101350549640481">16.1.&nbsp;WSDL and Message Level Interoperability</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>JAX-WS 2.1</p></li><li class="listitem"><p>JAXB 2.1</p></li><li class="listitem"><p>SAAJ</p></li><li class="listitem"><p>Stax</p></li><li class="listitem"><p>WS-I Basic Profile 1.2 and 2.0</p></li><li class="listitem"><p>WS-I Simple SOAP Binding Profile 1.0</p></li><li class="listitem"><p>WS-I Attachment Profile 1.0</p></li><li class="listitem"><p>SOAP 1.1 and SOAP 1.2</p></li><li class="listitem"><p>WSDL 1.1</p></li><li class="listitem"><p>Web Services Addressing 1.0 - Core, Web Services
                Addressing 1.0 - SOAP Binding and Web Services Addressing 1.0
                - Metadata</p></li><li class="listitem"><p>MTOM and SOAP With Attachments</p></li></ul></div></div><div class="section" title="16.2.&nbsp;.NET 3.5 Interoperability"><div class="titlepage"><div><div><h3 class="title" id="section-325661411410258">16.2.&nbsp;.NET 3.5 Interoperability</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Provided thru <a class="link" href="http://wsit.java.net" target="_top">WSIT</a> plugins.</p></li><li class="listitem"><p>JAX-WS 2.2.7
                 and WSIT plugins are
                tightly integrated in to <a class="link" href="http://glassfish.java.net/public/downloadsjax-ws-ri-overview" target="_top">GF
                v3.1</a></p></li><li class="listitem"><p>Tested for interoperability with .NET 3.0</p></li><li class="listitem"><p>.NET 3.0 interoperable WS-* features supported through
                WSIT </p><div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p>WS-ReliableMessaging</p></li><li class="listitem"><p>WS-Policy</p></li><li class="listitem"><p>WS-MEX</p></li><li class="listitem"><p>WS-Security/WS-Security Policy</p></li><li class="listitem"><p>WS-Trust/WS-Secure Conversation</p></li><li class="listitem"><p>WS-AT/WS-Tx (Supported only on Glassfish
                            v2)</p></li><li class="listitem"><p>WS-Addresssing</p></li><li class="listitem"><p>MTOM</p></li></ul></div></li><li class="listitem"><p>Get standalone consolidated bundle of JAX-WS
                2.2.7
                 and WSIT from <a class="link" href="http://metro.java.net/" target="_top">Metro
                website</a>.</p></li></ul></div><p>Send your feedback to <a class="link" href="mailto:users@jax-ws.java.net" target="_top">users@jaxws.dev.java.net</a>.</p></div></div><div lang="en" class="section" title="17.&nbsp;Endpoint API"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="users-guide-endpoint-api">17.&nbsp;Endpoint API</h2></div></div></div><p>Web Service endpoints can be created and published programmatically
    using <code class="literal">javax.xml.ws.Endpoint</code> API. An endpoint consists
    of a Web Service Implementation object and some configuration information.
    The implementation hosts the web service endpoint using a light weight
    http server and clients can access the web service as if the endpoint is
    deployed in a J2EE container. This means that there is no need to have any
    J2EE servlet or EJB container to host the endpoint. The
    <code class="literal">Endpoint</code> API provides a way to configure the endpoint
    with the necessary binding, metadata (WSDL and schema documents), handlers
    etc.</p><div class="section" title="17.1.&nbsp;Endpoint"><div class="titlepage"><div><div><h3 class="title" id="section-0499646435494807">17.1.&nbsp;<code class="literal">Endpoint</code></h3></div></div></div><p>An endpoint can be created using any of the following
        constructors:</p><div class="informalexample"><pre class="programlisting">Endpoint.create(implementor)</pre></div><div class="informalexample"><pre class="programlisting">Endpoint.create(bindingId,implementor)    </pre></div><div class="informalexample"><pre class="programlisting">Endpoint.publish(address, implementor)    </pre></div><p>Once the <code class="literal">Endpoint</code> object is created using the
        first two constructors, it can be published using
        <code class="literal">Endpoint.publish()</code>. Any published
        <code class="literal">Endpoint</code> can be stopped using
        <code class="literal">Endpoint.stop()</code>. <a class="link" href="../samples/supplychain/src/supplychain/server/WarehouseLightWeight.java" target="_top"><span class="application">supplychain</span></a>
        sample shows creating and publishing an
        <code class="literal">Endpoint</code>.</p></div><div class="section" title="17.2.&nbsp;Endpoint and Properties"><div class="titlepage"><div><div><h3 class="title" id="section-2491869058427427">17.2.&nbsp;<code class="literal">Endpoint</code> and
        <code class="literal">Properties</code></h3></div></div></div><p>An endpoint can be configured to match service name and port
        name of WSDL using properties. This overwrites implementor object's
        serviceName, portName from <code class="literal">@WebService</code> annotation.
        The port address for an endpoint is patched only if the corresponding
        port's service name, and port name in WSDL are matched.</p><div class="example"><a name="d0e7990"></a><p class="title"><b>Example&nbsp;37.&nbsp;<code class="literal">Endpoint</code> and
            <code class="literal">Properties</code> Example</b></p><div class="example-contents"><pre class="programlisting">Endpoint endpoint = ...

Map&lt;String, Object&gt; map = <span class="ReservedWord">new</span> HashMap&lt;String, Object&gt;();
map.put(Endpoint.WSDL_SERVICE, <span class="ReservedWord">new</span> QName(...));
map.put(Endpoint.WSDL_PORT, <span class="ReservedWord">new</span> QName(...));

endpoint.setProperties(map);</pre></div></div><br class="example-break"></div><div class="section" title="17.3.&nbsp;Endpoint and Binding"><div class="titlepage"><div><div><h3 class="title" id="section-9038221558727715">17.3.&nbsp;<code class="literal">Endpoint</code> and
        <code class="literal">Binding</code></h3></div></div></div><p>An endpoint can be configured for different bindings using
        binding ids. These binding ids are defined in JAX-WS API and endpoint
        can be configured by specifying <code class="literal">@BindingType</code>
        annotation or using binding id in the <code class="literal">Endpoint()</code>
        constructors. The parameter in constructor overwrites binding defined
        by <code class="literal">@BindingType</code> annotation. If the binding is not
        specified using <code class="literal">@BindingType</code> or using a parameter
        in <code class="literal">Endpoint()</code> constructor, the default binding is
        <code class="literal">SOAP1.1</code>/<code class="literal">HTTP</code>. Binding object is
        used to configure MTOM, handler chain etc. SOAP binding object is used
        to configure SOAP binding specifics like roles.</p><p>For example:</p><div class="example"><a name="d0e8032"></a><p class="title"><b>Example&nbsp;38.&nbsp;<code class="literal">Endpoint</code> and <code class="literal">Binding</code>
            Example</b></p><div class="example-contents"><p>The following configures the endpoint for
            <code class="literal">XML/HTTP</code> binding.</p><pre class="programlisting">Endpoint endpoint = Endpoint.create(HTTPBinding.HTTP_BINDING, 
        implementor);</pre><p>Working with a <code class="literal">Binding</code> object:</p><pre class="programlisting"><span class="Comment">// setting MTOM</span>
SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
binding.setMTOMEnabled(true);

<span class="Comment">// setting SOAP binding roles</span>
binding.setRoles(...);

<span class="Comment">// setting handler chain</span>
binding.setHandlerChain(...);</pre></div></div><br class="example-break"></div><div class="section" title="17.4.&nbsp;Endpoint and metadata"><div class="titlepage"><div><div><h3 class="title" id="section-091994350952741">17.4.&nbsp;<code class="literal">Endpoint</code> and
        <code class="literal">metadata</code></h3></div></div></div><p>When the service endpoint is created using existing java
        classes, the implementation dynamically generates and publishes WSDL
        and schema documents. But when the service endpoint is created using
        existing WSDL documents, the same WSDL documents can be used for
        publishing using metadata facility. When a <code class="literal">Source</code>
        object is created, set <code class="literal">systemId</code> always and make
        sure the imports are resolvable w.r.t
        <code class="literal">systemId</code>s.</p><div class="example"><a name="d0e8072"></a><p class="title"><b>Example&nbsp;39.&nbsp;<code class="literal">Endpoint</code> and <code class="literal">metadata</code>
            Example</b></p><div class="example-contents"><pre class="programlisting"><span class="Comment">// metadata processing for WSDL, schema files</span>
List&lt;File&gt; metadataFile =...
List&lt;Source&gt; metadata = <span class="ReservedWord">new</span> ArrayList&lt;Source&gt;();
<span class="ReservedWord">for</span> (File file : metadataFile) {
    Source source = <span class="ReservedWord">new</span> StreamSource(<span class="ReservedWord">new</span> FileInputStream(file));
    source.setSystemId(file.toURL().toExternalForm());
    metadata.add(source);
}
endpoint.setMetadata(metadata);</pre></div></div><br class="example-break"></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch02.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ch04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Release Notes&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Tools</td></tr></table></div></body></html>

[top] / java / jaxws / 2.0 / docs / ch03.html

contact | logmethods.com