cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache CXF Documentation > JAX-WS Configuration
Date Mon, 24 Dec 2012 11:24:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CXF20DOC&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CXF20DOC/JAX-WS+Configuration">JAX-WS Configuration</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~coheigea@apache.org">Colm O hEigeartaigh</a>
    </h4>
        <br/>
                         <h4>Changes (8)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| jaxws:handlers | The JAX-WS handlers for this endpoint.  A list of &lt;bean&gt;s or &lt;ref&gt;s.  Each should implement [javax.xml.ws.handler.Handler|http://java.sun.com/javase/6/docs/api/javax/xml/ws/handler/Handler.html] or [javax.xml.ws.handler.soap.SOAPHandler|http://java.sun.com/javase/6/docs/api/javax/xml/ws/handler/soap/SOAPHandler.html] (Note that {{@HandlerChain}} annotations on the service bean appear to be ignored) | <br>| jaxws:properties | A properties map which should be supplied to the JAX-WS endpoint. See below. | <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">| jaxws:dataBinding | You can specify the which DataBinding will be use in the endpoint , This can be supplied using the Spring &lt;bean class=&quot;MyDataBinding&quot;/&gt; syntax. | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">| jaxws:dataBinding | Which DataBinding to use in the endpoint. This can be supplied using the Spring &lt;bean class=&quot;MyDataBinding&quot;/&gt; syntax. | <br></td></tr>
            <tr><td class="diff-unchanged" >| jaxws:binding | You can specify the BindingFactory for this endpoint to use.  This can be supplied using the Spring &lt;bean class=&quot;MyBindingFactory&quot;/&gt; syntax. | <br>| jaxws:features | The features that hold the interceptors for this endpoint. A list of &lt;bean&gt;s or &lt;ref&gt;s | <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| jaxws:handlers | The JAX-WS handlers for this endpoint.  A list of {{&lt;bean&gt;}} or {{&lt;ref&gt;}} elements.  Each should implement [javax.xml.ws.handler.Handler|http://java.sun.com/javase/6/docs/api/javax/xml/ws/handler/Handler.html] or [javax.xml.ws.handler.soap.SOAPHandler|http://java.sun.com/javase/6/docs/api/javax/xml/ws/handler/soap/SOAPHandler.html].  These are more portable than CXF interceptors, but may cause the full message to be loaded in as a DOM (slower for large messages). | <br>| jaxws:properties | A properties map which should be supplied to the JAX-WS endpoint. See below. | <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">| jaxws:dataBinding | You can specify the which DataBinding will be use in the endpoint , This can be supplied using the Spring &lt;bean class=&quot;MyDataBinding&quot;/&gt; syntax. | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">| jaxws:dataBinding | Which DataBinding to use in the endpoint. This can be supplied using the Spring &lt;bean class=&quot;MyDataBinding&quot;/&gt; syntax. | <br></td></tr>
            <tr><td class="diff-unchanged" >| jaxws:binding | You can specify the BindingFactory for this endpoint to use.  This can be supplied using the Spring &lt;bean class=&quot;MyBindingFactory&quot;/&gt; syntax. | <br>| jaxws:conduitSelector | | <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| bus | A reference to a CXF bus bean.  Must be provided if, for example, handlers are used.  May require additional Spring context imports (e.g. to bring in the default CXF bus bean). | <br>| conduitSelector | | <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">| dataBinding | You can specify the which DataBinding will be use in the endpoint , This can be supplied using the Spring &lt;bean class=&quot;MyDataBinding&quot;/&gt; syntax. | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">| dataBinding | Which DataBinding to use in the endpoint. This can be supplied using the Spring &lt;bean class=&quot;MyDataBinding&quot;/&gt; syntax. | <br></td></tr>
            <tr><td class="diff-unchanged" >| properties | A properties map which should be supplied to the JAX-WS endpoint. | <br>| serviceFactory | | <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >         http://cxf.apache.org/jaxws  <br>         http://cxf.apache.org/schemas/jaxws.xsd&quot;&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >  &lt;jaxws:server id=&quot;inlineImplementor&quot; address=&quot;http://localhost:8080/simpleWithAddress&quot;&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >    &lt;jaxws:serviceBean&gt; <br>      &lt;bean class=&quot;org.apache.hello_soap_http.GreeterImpl&quot;/&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >      &lt;/bean&gt; <br>    &lt;/jaxws:invoker&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >    &lt;jaxws:dataBinding&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >      &lt;bean class=&quot;org.apache.cxf.jaxb.JAXBDataBinding&quot;&gt; <br>        &lt;property name=&quot;namespaceMap&quot;&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >          &lt;map&gt;
             &lt;entry&gt;
               &lt;key&gt;
                 &lt;value&gt;http://cxf.apache.org/anon_complex_type/&lt;/value&gt;
               &lt;/key&gt;
               &lt;value&gt;BeepBeep&lt;/value&gt;
             &lt;/entry&gt;
          &lt;/map&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >        &lt;/property&gt; <br>      &lt;/bean&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >    &lt;/jaxws:dataBinding&gt; <br></td></tr>
            <tr><td class="diff-unchanged" >  &lt;/jaxws:server&gt; <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >&lt;/beans&gt; <br>{code} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Since JAXWS frontend server and client spring configuration parser are inherited from simple front, <br>Please ref [Simple Frontend Configuration] for the attribute and elements definition.  <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Since JAX-WS frontend server and client spring configuration parser are inherited from the simple frontend, please see [Simple Frontend Configuration] for the attribute and element definitions.  <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>Please see the <a href="/confluence/display/CXF20DOC/Configuration" title="Configuration">Configuration</a> section to learn how to supply a configuration to CXF. The following sections include just JAX-WS specific configuration items.</p>

<h1><a name="JAX-WSConfiguration-ConfiguringanEndpoint"></a>Configuring an Endpoint</h1>

<p>A JAX-WS Endpoint can be configured in XML in addition to using the JAX-WS APIs. Once you've created your <a href="/confluence/display/CXF20DOC/Developing+a+Service" title="Developing a Service">server implementation</a>, you simply need to provide the class name and an address. Here is a simple example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
	<span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
	<span class="code-keyword">xmlns:jaxws</span>=<span class="code-quote">"http://cxf.apache.org/jaxws"</span>
	xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"&gt;

&lt;jaxws:endpoint id=<span class="code-quote">"classImpl"</span>
    implementor=<span class="code-quote">"org.apache.cxf.jaxws.service.Hello"</span>
    endpointName=<span class="code-quote">"e:HelloEndpointCustomized"</span>
    serviceName=<span class="code-quote">"s:HelloServiceCustomized"</span>
    address=<span class="code-quote">"http://localhost:8080/test"</span>
    <span class="code-keyword">xmlns:e</span>=<span class="code-quote">"http://service.jaxws.cxf.apache.org/endpoint"</span>
    <span class="code-keyword">xmlns:s</span>=<span class="code-quote">"http://service.jaxws.cxf.apache.org/service"</span>/&gt;

<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>
<p>Be sure to include the JAX-WS <tt>schemaLocation</tt> attribute specified on the root beans element. This allows CXF to validate the file and is required.  Also note the namespace declarations at the end of the &lt;jaxws:endpoint/&gt; tag--these are required because the combined "{namespace}localName" syntax is presently not supported for this tag's attribute values.</p>

<p>The <tt>jaxws:endpoint</tt> element (which appears to create an <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/jaxws/EndpointImpl.html" class="external-link" rel="nofollow">EndpointImpl</a> under the covers) supports many additional attributes:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Value </th>
</tr>
<tr>
<td class='confluenceTd'> endpointName </td>
<td class='confluenceTd'> The endpoint name this service is implementing, it maps to the wsdl:port@name. In the format of "ns:ENDPOINT_NAME" where ns is a namespace prefix valid at this scope. </td>
</tr>
<tr>
<td class='confluenceTd'> publish </td>
<td class='confluenceTd'> Whether the endpoint should be published now, or whether it will be published at a later point. </td>
</tr>
<tr>
<td class='confluenceTd'> serviceName </td>
<td class='confluenceTd'> The service name this service is implementing, it maps to the wsdl:service@name. In the format of "ns:SERVICE_NAME" where ns is a namespace prefix valid at this scope. </td>
</tr>
<tr>
<td class='confluenceTd'> wsdlLocation </td>
<td class='confluenceTd'> The location of the WSDL. Can be on the classpath, file system, or be hosted remotely. </td>
</tr>
<tr>
<td class='confluenceTd'> bindingUri </td>
<td class='confluenceTd'> The URI, or ID, of the message binding for the endpoint to use. For SOAP the binding URI(ID) is specified by the JAX-WS specification. For other message bindings the URI is the namespace of the WSDL extensions used to specify the binding. </td>
</tr>
<tr>
<td class='confluenceTd'> address </td>
<td class='confluenceTd'> The service publish address </td>
</tr>
<tr>
<td class='confluenceTd'> bus </td>
<td class='confluenceTd'> The bus name that will be used in the jaxws endpoint. </td>
</tr>
<tr>
<td class='confluenceTd'> implementor </td>
<td class='confluenceTd'> The implementor of jaxws endpoint. You can specify the implementor class name here, or just the ref bean name in the format of "#REF_BEAN_NAME" </td>
</tr>
<tr>
<td class='confluenceTd'> implementorClass </td>
<td class='confluenceTd'> The implementor class name, it is really useful when you specify the implementor with the ref bean which is wrapped by using Spring AOP </td>
</tr>
<tr>
<td class='confluenceTd'> createdFromAPI </td>
<td class='confluenceTd'> This indicates that the endpoint bean was already created using jaxws API's thus at runtime when parsing the bean spring can use these values rather than the default ones.  It's important that when this is true, the "name" of the bean is set to the port name of the endpoint being created in the form "{http://service.target.namespace} PortName".</td>
</tr>
<tr>
<td class='confluenceTd'> publishedEndpointUrl </td>
<td class='confluenceTd'> The URL that is placed in the address element of the wsdl when the wsdl is retrieved.   If not specified, the address listed above is used.  This parameter allows setting the "public" URL that may not be the same as the URL the service is deployed on. (for example, the service is behind a proxy of some sort).</td>
</tr>
</tbody></table>
</div>


<p>It also supports many child elements:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Value </th>
</tr>
<tr>
<td class='confluenceTd'> jaxws:executor </td>
<td class='confluenceTd'> A Java executor which will be used for the service. This can be supplied using the Spring &lt;bean class="MyExecutor"/&gt; syntax. </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:inInterceptors </td>
<td class='confluenceTd'> The incoming interceptors for this endpoint. A list of &lt;bean&gt;s or &lt;ref&gt;s.  Each should implement <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/Interceptor.html" class="external-link" rel="nofollow">org.apache.cxf.interceptor.Interceptor</a> or <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/phase/PhaseInterceptor.html" class="external-link" rel="nofollow">org.apache.cxf.phase.PhaseInterceptor</a> </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:inFaultInterceptors </td>
<td class='confluenceTd'> The incoming fault interceptors for this endpoint.  A list of &lt;bean&gt;s or &lt;ref&gt;s.  Each should implement <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/Interceptor.html" class="external-link" rel="nofollow">org.apache.cxf.interceptor.Interceptor</a> or <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/phase/PhaseInterceptor.html" class="external-link" rel="nofollow">org.apache.cxf.phase.PhaseInterceptor</a> </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:outInterceptors </td>
<td class='confluenceTd'> The outgoing interceptors for this endpoint. A list of &lt;bean&gt;s or &lt;ref&gt;s.  Each should implement <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/Interceptor.html" class="external-link" rel="nofollow">org.apache.cxf.interceptor.Interceptor</a> or <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/phase/PhaseInterceptor.html" class="external-link" rel="nofollow">org.apache.cxf.phase.PhaseInterceptor</a> </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:outFaultInterceptors </td>
<td class='confluenceTd'> The outgoing fault interceptors for this endpoint. A list of &lt;bean&gt;s or &lt;ref&gt;s.  Each should implement <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/Interceptor.html" class="external-link" rel="nofollow">org.apache.cxf.interceptor.Interceptor</a> or <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/phase/PhaseInterceptor.html" class="external-link" rel="nofollow">org.apache.cxf.phase.PhaseInterceptor</a> </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:handlers </td>
<td class='confluenceTd'> The JAX-WS handlers for this endpoint.  A list of &lt;bean&gt;s or &lt;ref&gt;s.  Each should implement <a href="http://java.sun.com/javase/6/docs/api/javax/xml/ws/handler/Handler.html" class="external-link" rel="nofollow">javax.xml.ws.handler.Handler</a> or <a href="http://java.sun.com/javase/6/docs/api/javax/xml/ws/handler/soap/SOAPHandler.html" class="external-link" rel="nofollow">javax.xml.ws.handler.soap.SOAPHandler</a> (Note that <tt>@HandlerChain</tt> annotations on the service bean appear to be ignored) </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:properties </td>
<td class='confluenceTd'> A properties map which should be supplied to the JAX-WS endpoint. See below. </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:dataBinding </td>
<td class='confluenceTd'> Which DataBinding to use in the endpoint. This can be supplied using the Spring &lt;bean class="MyDataBinding"/&gt; syntax. </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:binding </td>
<td class='confluenceTd'> You can specify the BindingFactory for this endpoint to use.  This can be supplied using the Spring &lt;bean class="MyBindingFactory"/&gt; syntax. </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:features </td>
<td class='confluenceTd'> The features that hold the interceptors for this endpoint. A list of &lt;bean&gt;s or &lt;ref&gt;s </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:invoker </td>
<td class='confluenceTd'> The invoker which will be supplied to this endpoint. This can be supplied using the Spring &lt;bean class="MyInvoker"/&gt; syntax. </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:schemaLocations </td>
<td class='confluenceTd'> The schema locations for endpoint to use. A list of &lt;schemaLocation&gt;s </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:serviceFactory </td>
<td class='confluenceTd'> The service factory for this endpoint to use. This can be supplied using the Spring &lt;bean class="MyServiceFactory"/&gt; syntax </td>
</tr>
</tbody></table>
</div>

<p>Here is a more advanced example which shows how to provide interceptors and properties:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
	<span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
	<span class="code-keyword">xmlns:jaxws</span>=<span class="code-quote">"http://cxf.apache.org/jaxws"</span>
        <span class="code-keyword">xmlns:soap</span>=<span class="code-quote">"http://cxf.apache.org/bindings/soap"</span>
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://cxf.apache.org/bindings/soap 
           http://cxf.apache.org/schemas/configuration/soap.xsd
           http://cxf.apache.org/jaxws 
           http://cxf.apache.org/schemas/jaxws.xsd"&gt;

  <span class="code-tag">&lt;import resource=<span class="code-quote">"classpath:META-INF/cxf/cxf.xml"</span>/&gt;</span>
  <span class="code-tag">&lt;import resource=<span class="code-quote">"classpath:META-INF/cxf/cxf-extension-soap.xml"</span>/&gt;</span>

  &lt;jaxws:endpoint
    id=<span class="code-quote">"helloWorld"</span>
    implementor=<span class="code-quote">"demo.spring.HelloWorldImpl"</span>
    address=<span class="code-quote">"http://localhost/HelloWorld"</span>&gt;
    <span class="code-tag">&lt;jaxws:inInterceptors&gt;</span>
      <span class="code-tag">&lt;bean class=<span class="code-quote">"com.acme.SomeInterceptor"</span>/&gt;</span>
      <span class="code-tag">&lt;ref bean=<span class="code-quote">"anotherInterceptor"</span>/&gt;</span>
    <span class="code-tag">&lt;/jaxws:inInterceptor&gt;</span>
    <span class="code-tag">&lt;jaxws:properties&gt;</span>
      <span class="code-tag">&lt;entry key=<span class="code-quote">"mtom-enabled"</span> value=<span class="code-quote">"true"</span>/&gt;</span>
    <span class="code-tag">&lt;/jaxws:properties&gt;</span>
  <span class="code-tag">&lt;/jaxws:endpoint&gt;</span>

  <span class="code-tag">&lt;bean id=<span class="code-quote">"anotherInterceptor"</span> class=<span class="code-quote">"com.acme.SomeInterceptor"</span>/&gt;</span>

  &lt;jaxws:endpoint id=<span class="code-quote">"simpleWithBinding"</span>
    implementor=<span class="code-quote">"#greeter"</span> 
        address=<span class="code-quote">"http://localhost:8080/simpleWithAddress"</span>&gt;
  	<span class="code-tag">&lt;jaxws:binding&gt;</span>
  	   <span class="code-tag">&lt;soap:soapBinding mtomEnabled=<span class="code-quote">"true"</span> version=<span class="code-quote">"1.2"</span>/&gt;</span>
  	<span class="code-tag">&lt;/jaxws:binding&gt;</span>
  <span class="code-tag">&lt;/jaxws:endpoint&gt;</span>

  &lt;jaxws:endpoint id=<span class="code-quote">"inlineInvoker"</span> 
    address=<span class="code-quote">"http://localhost:8080/simpleWithAddress"</span>&gt;
    <span class="code-tag">&lt;jaxws:implementor&gt;</span>
      <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.hello_world_soap_http.GreeterImpl"</span>/&gt;</span>
    <span class="code-tag">&lt;/jaxws:implementor&gt;</span>
    <span class="code-tag">&lt;jaxws:invoker&gt;</span>
      <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.cxf.jaxws.spring.NullInvoker"</span>/&gt;</span>
    <span class="code-tag">&lt;/jaxws:invoker&gt;</span>
  <span class="code-tag">&lt;/jaxws:endpoint&gt;</span>

<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>
<p>If you are a Spring user, you'll notice that the <tt>jaxws:properties</tt> element follows the Spring Map syntax.</p>

<h1><a name="JAX-WSConfiguration-ConfiguringaSpringClient%28Option1%29"></a>Configuring a Spring Client (Option 1)</h1>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>This technique lets you add a Web Services client to your Spring application.  You can inject it into other Spring beans, or manually retrieve it from the Spring context for use by non-Spring-aware client code.</td></tr></table></div>
<p>The easiest way to add a Web Services client to a Spring context is to use the <tt>&lt;jaxws:client&gt;</tt> element (similar to the <tt>&lt;jaxws:endpoint&gt;</tt> element used for the server side).  Here's a simple example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span> encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
       <span class="code-keyword">xmlns:jaxws</span>=<span class="code-quote">"http://cxf.apache.org/jaxws"</span>
       <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
       xsi:schemaLocation="
          http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans.xsd
          http://cxf.apache.org/jaxws 
          http://cxf.apache.org/schemas/jaxws.xsd"&gt;

    &lt;jaxws:client id=<span class="code-quote">"helloClient"</span>
                  serviceClass=<span class="code-quote">"demo.spring.HelloWorld"</span>
                  address=<span class="code-quote">"http://localhost:9002/HelloWorld"</span> /&gt;
<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>
<p>The attributes available on <tt>&lt;jaxws:client&gt;</tt> include:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> id </td>
<td class='confluenceTd'> String </td>
<td class='confluenceTd'> A unique identified for the client, which is how other beans in the context will reference it </td>
</tr>
<tr>
<td class='confluenceTd'> address </td>
<td class='confluenceTd'> URL </td>
<td class='confluenceTd'> The URL to connect to in order to invoke the service </td>
</tr>
<tr>
<td class='confluenceTd'> serviceClass </td>
<td class='confluenceTd'> Class </td>
<td class='confluenceTd'> The fully-qualified name of the interface that the bean should implement (typically, same as the service interface used on the server side) </td>
</tr>
<tr>
<td class='confluenceTd'> serviceName </td>
<td class='confluenceTd'> QName </td>
<td class='confluenceTd'> The name of the service to invoke, if this address/WSDL hosts several.  It maps to the wsdl:service@name. In the format of "ns:SERVICE_NAME" where ns is a namespace prefix valid at this scope. </td>
</tr>
<tr>
<td class='confluenceTd'> endpointName </td>
<td class='confluenceTd'> QName </td>
<td class='confluenceTd'> The name of the endpoint to invoke, if this address/WSDL hosts several.  It maps to the wsdl:port@name. In the format of "ns:ENDPOINT_NAME" where ns is a namespace prefix valid at this scope. </td>
</tr>
<tr>
<td class='confluenceTd'> bindingId </td>
<td class='confluenceTd'> URI </td>
<td class='confluenceTd'> The URI, or ID, of the message binding for the endpoint to use. For SOAP the binding URI(ID) is specified by the JAX-WS specification. For other message bindings the URI is the namespace of the WSDL extensions used to specify the binding. </td>
</tr>
<tr>
<td class='confluenceTd'> bus </td>
<td class='confluenceTd'> Bean Reference </td>
<td class='confluenceTd'> The bus name that will be used in the jaxws endpoint (defaults to <tt>cxf</tt>). </td>
</tr>
<tr>
<td class='confluenceTd'> username </td>
<td class='confluenceTd'> String </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> password </td>
<td class='confluenceTd'> String </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> wsdlLocation </td>
<td class='confluenceTd'> URL </td>
<td class='confluenceTd'> A URL to connect to in order to retrieve the WSDL for the service.  This is not required. </td>
</tr>
<tr>
<td class='confluenceTd'> createdFromAPI </td>
<td class='confluenceTd'> boolean </td>
<td class='confluenceTd'> This indicates that the client bean was already created using jaxws API's thus at runtime when parsing the bean spring can use these values rather than the default ones.  It's important that when this is true, the "name" of the bean is set to the port name of the endpoint being created in the form "{http://service.target.namespace}PortName".</td>
</tr>
</tbody></table>
</div>

<p>It also supports many child elements:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> jaxws:inInterceptors </td>
<td class='confluenceTd'> The incoming interceptors for this endpoint. A list of <tt>&lt;bean&gt;</tt> or <tt>&lt;ref&gt;</tt> elements.  Each should implement <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/Interceptor.html" class="external-link" rel="nofollow">org.apache.cxf.interceptor.Interceptor</a> or <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/phase/PhaseInterceptor.html" class="external-link" rel="nofollow">org.apache.cxf.phase.PhaseInterceptor</a> </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:inFaultInterceptors </td>
<td class='confluenceTd'> The incoming fault interceptors for this endpoint.  A list of <tt>&lt;bean&gt;</tt> or <tt>&lt;ref&gt;</tt> elements.  Each should implement <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/Interceptor.html" class="external-link" rel="nofollow">org.apache.cxf.interceptor.Interceptor</a> or <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/phase/PhaseInterceptor.html" class="external-link" rel="nofollow">org.apache.cxf.phase.PhaseInterceptor</a> </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:outInterceptors </td>
<td class='confluenceTd'> The outgoing interceptors for this endpoint. A list of <tt>&lt;bean&gt;</tt> or <tt>&lt;ref&gt;</tt> elements.  Each should implement <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/Interceptor.html" class="external-link" rel="nofollow">org.apache.cxf.interceptor.Interceptor</a> or <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/phase/PhaseInterceptor.html" class="external-link" rel="nofollow">org.apache.cxf.phase.PhaseInterceptor</a> </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:outFaultInterceptors </td>
<td class='confluenceTd'> The outgoing fault interceptors for this endpoint. A list of <tt>&lt;bean&gt;</tt> or <tt>&lt;ref&gt;</tt> elements.  Each should implement <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/Interceptor.html" class="external-link" rel="nofollow">org.apache.cxf.interceptor.Interceptor</a> or <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/phase/PhaseInterceptor.html" class="external-link" rel="nofollow">org.apache.cxf.phase.PhaseInterceptor</a> </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:features </td>
<td class='confluenceTd'> The features that hold the interceptors for this endpoint. A list of <tt>&lt;bean&gt;</tt> or <tt>&lt;ref&gt;</tt> elements </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:handlers </td>
<td class='confluenceTd'> The JAX-WS handlers for this endpoint.  A list of <tt>&lt;bean&gt;</tt> or <tt>&lt;ref&gt;</tt> elements.  Each should implement <a href="http://java.sun.com/javase/6/docs/api/javax/xml/ws/handler/Handler.html" class="external-link" rel="nofollow">javax.xml.ws.handler.Handler</a> or <a href="http://java.sun.com/javase/6/docs/api/javax/xml/ws/handler/soap/SOAPHandler.html" class="external-link" rel="nofollow">javax.xml.ws.handler.soap.SOAPHandler</a>.  These are more portable than CXF interceptors, but may cause the full message to be loaded in as a DOM (slower for large messages). </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:properties </td>
<td class='confluenceTd'> A properties map which should be supplied to the JAX-WS endpoint. See below. </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:dataBinding </td>
<td class='confluenceTd'> Which DataBinding to use in the endpoint. This can be supplied using the Spring &lt;bean class="MyDataBinding"/&gt; syntax. </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:binding </td>
<td class='confluenceTd'> You can specify the BindingFactory for this endpoint to use.  This can be supplied using the Spring &lt;bean class="MyBindingFactory"/&gt; syntax. </td>
</tr>
<tr>
<td class='confluenceTd'> jaxws:conduitSelector </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
</tbody></table>
</div>

<p>Here is a more advanced example which shows how to provide interceptors, JAX-WS handlers, and properties:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span> encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
       <span class="code-keyword">xmlns:jaxws</span>=<span class="code-quote">"http://cxf.apache.org/jaxws"</span>
       <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
       xsi:schemaLocation="
          http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans.xsd
          http://cxf.apache.org/jaxws 
          http://cxf.apache.org/schemas/jaxws.xsd"&gt;

  &lt;!-- Interceptors extend e.g. 
       org.apache.cxf.phase.AbstractPhaseInterceptor --&gt;
  <span class="code-tag">&lt;bean id=<span class="code-quote">"anotherInterceptor"</span> class=<span class="code-quote">"..."</span> /&gt;</span>

  <span class="code-tag"><span class="code-comment">&lt;!-- Handlers implement e.g. javax.xml.ws.handler.soap.SOAPHandler --&gt;</span></span>
  <span class="code-tag">&lt;bean id=<span class="code-quote">"jaxwsHandler"</span> class=<span class="code-quote">"..."</span> /&gt;</span>

  <span class="code-tag"><span class="code-comment">&lt;!-- The SOAP client bean --&gt;</span></span>
  &lt;jaxws:client id=<span class="code-quote">"helloClient"</span>
                serviceClass=<span class="code-quote">"demo.spring.HelloWorld"</span>
                address=<span class="code-quote">"http://localhost:9002/HelloWorld"</span>&gt;
    <span class="code-tag">&lt;jaxws:inInterceptors&gt;</span>
      <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.cxf.interceptor.LoggingInInterceptor"</span>/&gt;</span>
      <span class="code-tag">&lt;ref bean=<span class="code-quote">"anotherInterceptor"</span>/&gt;</span>
    <span class="code-tag">&lt;/jaxws:inInterceptor&gt;</span>
    <span class="code-tag">&lt;jaxws:handlers&gt;</span>
      <span class="code-tag">&lt;ref bean=<span class="code-quote">"jaxwsHandler"</span> /&gt;</span>
    <span class="code-tag">&lt;/jaxws:handlers&gt;</span>
    <span class="code-tag">&lt;jaxws:properties&gt;</span>
      <span class="code-tag">&lt;entry key=<span class="code-quote">"mtom-enabled"</span> value=<span class="code-quote">"true"</span>/&gt;</span>
    <span class="code-tag">&lt;/jaxws:properties&gt;</span>
  <span class="code-tag">&lt;/jaxws:client&gt;</span>
<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>

<h1><a name="JAX-WSConfiguration-ConfiguringaSpringClient%28Option2%29"></a>Configuring a Spring Client (Option 2)</h1>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Building a Client using this configuration is only applicable for those wishing to inject a Client into their Spring ApplicationContext.</td></tr></table></div>
<p>This approach requires more explicit Spring bean configuration than the previous option, and may require more configuration data depending on which features are used.  To configure a client this way, you'll need to declare a proxy factory bean and also a client bean which is created by that proxy factory. Here is an example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
  <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
  <span class="code-keyword">xmlns:jaxws</span>=<span class="code-quote">"http://cxf.apache.org/jaxws"</span>
  xsi:schemaLocation="
      http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      http://cxf.apache.org/jaxws 
      http://cxf.apache.org/schemas/jaxws.xsd"&gt;

  &lt;bean id=<span class="code-quote">"proxyFactory"</span> 
    class=<span class="code-quote">"org.apache.cxf.jaxws.JaxWsProxyFactoryBean"</span>&gt;
    <span class="code-tag">&lt;property name=<span class="code-quote">"serviceClass"</span> value=<span class="code-quote">"demo.spring.HelloWorld"</span>/&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"address"</span> value=<span class="code-quote">"http://localhost:9002/HelloWorld"</span>/&gt;</span>
  <span class="code-tag">&lt;/bean&gt;</span>

  &lt;bean id=<span class="code-quote">"client"</span> class=<span class="code-quote">"demo.spring.HelloWorld"</span>
    factory-bean=<span class="code-quote">"proxyFactory"</span> factory-method=<span class="code-quote">"create"</span>/&gt;

<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>
<p>The JaxWsProxyFactoryBean in this case takes two properties. The service class, which is the interface of the Client proxy you wish to create. The address is the address of the service you wish to call.</p>

<p>The second bean definition is for the client. In this case it implements the HelloWorld interface and is created by the proxyFactory &lt;bean&gt; by calling the create() method. You can then reference this "client" bean and inject it anywhere into your application. Here is an example of a very simple Java class which accesses the client bean:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
include org.springframework.context.support.ClassPathXmlApplicationContext;

<span class="code-keyword">public</span> <span class="code-keyword">final</span> class HelloWorldClient {

     <span class="code-keyword">private</span> HelloWorldClient() { }

     <span class="code-keyword">public</span> <span class="code-keyword">static</span> void main(<span class="code-object">String</span> args[]) <span class="code-keyword">throws</span> Exception {
         ClassPathXmlApplicationContext context 
            = <span class="code-keyword">new</span> ClassPathXmlApplicationContext(
               <span class="code-keyword">new</span> <span class="code-object">String</span>[]{<span class="code-quote">"my/path/to/client-beans.xml"</span>});

         HelloWorld client = (HelloWorld)context.getBean(<span class="code-quote">"client"</span>);

         <span class="code-object">String</span> response = client.sayHi(<span class="code-quote">"Dan"</span>);
         <span class="code-object">System</span>.out.println(<span class="code-quote">"Response: "</span> + response);
         <span class="code-object">System</span>.exit(0);
     }
}
</pre>
</div></div>
<p>The JaxWsProxyFactoryBean supports many other properties:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> clientFactoryBean </td>
<td class='confluenceTd'> The ClientFactoryBean used in construction of this proxy. </td>
</tr>
<tr>
<td class='confluenceTd'> password </td>
<td class='confluenceTd'> The password which the transport should use. </td>
</tr>
<tr>
<td class='confluenceTd'> username </td>
<td class='confluenceTd'> The username which the transport should use. </td>
</tr>
<tr>
<td class='confluenceTd'> wsdlURL </td>
<td class='confluenceTd'> The wsdl URL the client should use to configure itself. </td>
</tr>
<tr>
<td class='confluenceTd'> wsdlLocation </td>
<td class='confluenceTd'> Appears to be the same as wsdlURL? </td>
</tr>
<tr>
<td class='confluenceTd'> serviceName </td>
<td class='confluenceTd'> The name of the service to invoke, if this address/WSDL hosts several.  It maps to the wsdl:service@name. In the format of "ns:SERVICE_NAME" where ns is a namespace prefix valid at this scope. </td>
</tr>
<tr>
<td class='confluenceTd'> endpointName </td>
<td class='confluenceTd'> The name of the endpoint to invoke, if this address/WSDL hosts several.  It maps to the wsdl:port@name. In the format of "ns:ENDPOINT_NAME" where ns is a namespace prefix valid at this scope. </td>
</tr>
<tr>
<td class='confluenceTd'> inInterceptors </td>
<td class='confluenceTd'> The incoming interceptors for this endpoint. A list of <tt>&lt;bean&gt;</tt> or <tt>&lt;ref&gt;</tt> elements.  Each should implement <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/Interceptor.html" class="external-link" rel="nofollow">org.apache.cxf.interceptor.Interceptor</a> or <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/phase/PhaseInterceptor.html" class="external-link" rel="nofollow">org.apache.cxf.phase.PhaseInterceptor</a> </td>
</tr>
<tr>
<td class='confluenceTd'> inFaultInterceptors </td>
<td class='confluenceTd'> The incoming fault interceptors for this endpoint.  A list of <tt>&lt;bean&gt;</tt> or <tt>&lt;ref&gt;</tt> elements.  Each should implement <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/Interceptor.html" class="external-link" rel="nofollow">org.apache.cxf.interceptor.Interceptor</a> or <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/phase/PhaseInterceptor.html" class="external-link" rel="nofollow">org.apache.cxf.phase.PhaseInterceptor</a> </td>
</tr>
<tr>
<td class='confluenceTd'> outInterceptors </td>
<td class='confluenceTd'> The outgoing interceptors for this endpoint. A list of <tt>&lt;bean&gt;</tt> or <tt>&lt;ref&gt;</tt> elements.  Each should implement <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/Interceptor.html" class="external-link" rel="nofollow">org.apache.cxf.interceptor.Interceptor</a> or <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/phase/PhaseInterceptor.html" class="external-link" rel="nofollow">org.apache.cxf.phase.PhaseInterceptor</a> </td>
</tr>
<tr>
<td class='confluenceTd'> outFaultInterceptors </td>
<td class='confluenceTd'> The outgoing fault interceptors for this endpoint. A list of <tt>&lt;bean&gt;</tt> or <tt>&lt;ref&gt;</tt> elements.  Each should implement <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/Interceptor.html" class="external-link" rel="nofollow">org.apache.cxf.interceptor.Interceptor</a> or <a href="http://cxf.apache.org/javadoc/latest/org/apache/cxf/phase/PhaseInterceptor.html" class="external-link" rel="nofollow">org.apache.cxf.phase.PhaseInterceptor</a> </td>
</tr>
<tr>
<td class='confluenceTd'> features </td>
<td class='confluenceTd'> The features that hold the interceptors for this endpoint. A list of <tt>&lt;bean&gt;</tt> or <tt>&lt;ref&gt;</tt> elements </td>
</tr>
<tr>
<td class='confluenceTd'> handlers </td>
<td class='confluenceTd'> A list of <tt>&lt;bean&gt;</tt> or <tt>&lt;ref&gt;</tt> elements pointing to JAX-WS handler classes to be used for this client.  Each should implement <a href="http://java.sun.com/javase/6/docs/api/javax/xml/ws/handler/Handler.html" class="external-link" rel="nofollow">javax.xml.ws.handler.Handler</a> or <a href="http://java.sun.com/javase/6/docs/api/javax/xml/ws/handler/soap/SOAPHandler.html" class="external-link" rel="nofollow">javax.xml.ws.handler.soap.SOAPHandler</a>.  These are more portable than CXF interceptors, but may cause the full message to be loaded in as a DOM (slower for large messages). </td>
</tr>
<tr>
<td class='confluenceTd'> bindingConfig </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> bindingId </td>
<td class='confluenceTd'> The URI, or ID, of the message binding for the endpoint to use. For SOAP the binding URI(ID) is specified by the JAX-WS specification. For other message bindings the URI is the namespace of the WSDL extensions used to specify the binding. </td>
</tr>
<tr>
<td class='confluenceTd'> bus </td>
<td class='confluenceTd'> A reference to a CXF bus bean.  Must be provided if, for example, handlers are used.  May require additional Spring context imports (e.g. to bring in the default CXF bus bean). </td>
</tr>
<tr>
<td class='confluenceTd'> conduitSelector </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> dataBinding </td>
<td class='confluenceTd'> Which DataBinding to use in the endpoint. This can be supplied using the Spring &lt;bean class="MyDataBinding"/&gt; syntax. </td>
</tr>
<tr>
<td class='confluenceTd'> properties </td>
<td class='confluenceTd'> A properties map which should be supplied to the JAX-WS endpoint. </td>
</tr>
<tr>
<td class='confluenceTd'> serviceFactory </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
</tbody></table>
</div>

<p>Using some of the properties will require additional configuration in the Spring context.  For instance, using JAX-WS handlers requires that you explicitly import several CXF Spring configurations, and assign the "bus" property of the JaxWsProxyFactory bean like this:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;import resource=<span class="code-quote">"classpath:META-INF/cxf/cxf.xml"</span> /&gt;</span>
<span class="code-tag">&lt;import resource=<span class="code-quote">"classpath:META-INF/cxf/cxf-extension-soap.xml"</span> /&gt;</span>
<span class="code-tag">&lt;import resource=<span class="code-quote">"classpath:META-INF/cxf/cxf-extension-http.xml"</span> /&gt;</span>

<span class="code-tag">&lt;bean id=<span class="code-quote">"clientFactory"</span> class=<span class="code-quote">"org.apache.cxf.jaxws.JaxWsProxyFactoryBean"</span>&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"serviceClass"</span> value=<span class="code-quote">"demo.spring.HelloWorld"</span>/&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"address"</span> value=<span class="code-quote">"http://localhost:9002/HelloWorld"</span>/&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"bus"</span> ref=<span class="code-quote">"cxf"</span> /&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>
</pre>
</div></div>

<h1><a name="JAX-WSConfiguration-ConfiguringanEndpoint%2FClientProxyUsingCXFAPIs"></a>Configuring an Endpoint/Client Proxy Using CXF APIs</h1>

<p>JAX-WS endpoints and client proxies are implemented on top of CXF's frontend-neutral endpoint API. You can therefore use CXF APIs to enhance the functionality of a JAX-WS endpoint or client proxy, for example by adding interceptors.</p>

<p>To cast a client proxy to a CXF client:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
GreeterService gs = <span class="code-keyword">new</span> GreeterService();
Greeter greeter = gs.getGreeterPort();

org.apache.cxf.endpoint.Client client =
org.apache.cxf.frontend.ClientProxy.getClient(greeter);
org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
cxfEndpoint.getOutInterceptors().add(...);
</pre>
</div></div>
<p>To cast a JAX-WS endpoint to a CXF server:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
javax.xml.ws.Endpoint jaxwsEndpoint = javax.xml.ws.Endpoint.publish(
   <span class="code-quote">"http:<span class="code-comment">//localhost:9020/SoapContext/GreeterPort"</span>, <span class="code-keyword">new</span> GreeterImpl());
</span>org.apache.cxf.jaxws.EndpointImpl jaxwsEndpointImpl = 
   (org.apache.cxf.jaxws.EndpointImpl)jaxwsEndpoint;
org.apache.cxf.endpoint.Server server = jaxwsEndpointImpl.getServer();
org.apache.cxf.endpoint.Endpoint cxfEndpoint = server.getEndpoint();
cxfEndpoint.getOutInterceptors().add(...);
org.apache.cxf.service.Service cxfService = cxfEndpoint.getService();
cxfService.getOutInterceptors().add(...);
</pre>
</div></div>

<h1><a name="JAX-WSConfiguration-ConfiguretheJAXWSServer%2FClientUsingSpring"></a>Configure the JAXWS Server/Client Using Spring</h1>

<p>CXF provides &lt;jaxws:server&gt;, &lt;jaxws:client&gt; to configure the server/client side endpoint. Here are some examples:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
      <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
      <span class="code-keyword">xmlns:jaxws</span>=<span class="code-quote">"http://cxf.apache.org/jaxws"</span>
      <span class="code-keyword">xmlns:soap</span>=<span class="code-quote">"http://cxf.apache.org/bindings/soap"</span>
      xsi:schemaLocation="
         http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
         http://cxf.apache.org/bindings/soap 
         http://cxf.apache.org/schemas/configuration/soap.xsd
         http://cxf.apache.org/jaxws 
         http://cxf.apache.org/schemas/jaxws.xsd"&gt;
  <span class="code-tag">&lt;jaxws:server id=<span class="code-quote">"inlineImplementor"</span> address=<span class="code-quote">"http://localhost:8080/simpleWithAddress"</span>&gt;</span>
    <span class="code-tag">&lt;jaxws:serviceBean&gt;</span>
      <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.hello_soap_http.GreeterImpl"</span>/&gt;</span>
    <span class="code-tag">&lt;/jaxws:serviceBean&gt;</span>
  <span class="code-tag">&lt;/jaxws:server&gt;</span>

  &lt;jaxws:server id=<span class="code-quote">"bookServer"</span> serviceClass=
      <span class="code-quote">"org.apache.cxf.mytype.AnonymousComplexTypeImpl"</span>
    address=<span class="code-quote">"http://localhost:8080/act"</span>
    bus=<span class="code-quote">"cxf"</span>&gt;
    <span class="code-tag">&lt;jaxws:invoker&gt;</span>
      <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.cxf.service.invoker.BeanInvoker"</span>&gt;</span>
        <span class="code-tag">&lt;constructor-arg&gt;</span>
          <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.cxf.mytype.AnonymousComplexTypeImpl"</span>/&gt;</span>
        <span class="code-tag">&lt;/constructor-arg&gt;</span>
      <span class="code-tag">&lt;/bean&gt;</span>
    <span class="code-tag">&lt;/jaxws:invoker&gt;</span>
    <span class="code-tag">&lt;jaxws:dataBinding&gt;</span>
      <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.cxf.jaxb.JAXBDataBinding"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"namespaceMap"</span>&gt;</span>
          <span class="code-tag">&lt;map&gt;</span>
             <span class="code-tag">&lt;entry&gt;</span>
               <span class="code-tag">&lt;key&gt;</span>
                 <span class="code-tag">&lt;value&gt;</span>http://cxf.apache.org/anon_complex_type/<span class="code-tag">&lt;/value&gt;</span>
               <span class="code-tag">&lt;/key&gt;</span>
               <span class="code-tag">&lt;value&gt;</span>BeepBeep<span class="code-tag">&lt;/value&gt;</span>
             <span class="code-tag">&lt;/entry&gt;</span>
          <span class="code-tag">&lt;/map&gt;</span>
        <span class="code-tag">&lt;/property&gt;</span>
      <span class="code-tag">&lt;/bean&gt;</span>
    <span class="code-tag">&lt;/jaxws:dataBinding&gt;</span>
  <span class="code-tag">&lt;/jaxws:server&gt;</span>

  &lt;jaxws:client id=<span class="code-quote">"bookClient"</span>
    serviceClass=<span class="code-quote">"org.apache.cxf.mytype.AnonymousComplexType"</span>
    address=<span class="code-quote">"http://localhost:8080/act"</span>/&gt;

<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>
<p>Since JAX-WS frontend server and client spring configuration parser are inherited from the simple frontend, please see <a href="/confluence/display/CXF20DOC/Simple+Frontend+Configuration" title="Simple Frontend Configuration">Simple Frontend Configuration</a> for the attribute and element definitions. </p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action" class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/JAX-WS+Configuration">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=49965&revisedVersion=35&originalVersion=34">View Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/JAX-WS+Configuration?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message