Modified: websites/production/cxf/content/docs/developing-a-consumer.html
==============================================================================
--- websites/production/cxf/content/docs/developing-a-consumer.html (original)
+++ websites/production/cxf/content/docs/developing-a-consumer.html Wed Sep 13
15:05:52 2017
@@ -32,8 +32,8 @@
<link type="text/css" rel="stylesheet"
href="/resources/highlighter/styles/shThemeCXF.css">
<script src='/resources/highlighter/scripts/shCore.js'></script>
-<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script src='/resources/highlighter/scripts/shBrushBash.js'></script>
+<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script>
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
@@ -118,7 +118,7 @@ Apache CXF -- Developing a Consumer
<!-- Content -->
<div class="wiki-content">
<div id="ConfluenceContent"><h1
id="DevelopingaConsumer-DevelopingaConsumerwithCXF">Developing a Consumer with
CXF</h1><h2 id="DevelopingaConsumer-GeneratingtheStubCode">Generating the Stub
Code</h2><p>The starting point for developing a service consumer (or client) in
CXF is a WSDL contract, complete with port type, binding, and service
definitions. You can then use the <a shape="rect"
href="wsdl-to-java.html">wsdl2java</a> utility to generate the Java stub code
from the WSDL contract. The stub code provides the supporting code that is
required to invoke operations on the remote service.<br clear="none"> For CXF
clients, the wsdl2java utility can generate the following kinds of
code:</p><ul><li>Stub code - supporting files for implementing a CXF
client.</li><li>Client starting point code - sample client code that connects
to the remote service and invokes every operation on the remote
service.</li><li>Ant build file - a <code>build.xml</code> file intended for
use with the ant buil
d utility. It has targets for building and for running the sample client
application.</li></ul><h4
id="DevelopingaConsumer-BasicHelloWorldWSDLcontract">Basic HelloWorld WSDL
contract</h4><p>The below shows the HelloWorld WSDL contract. This contract
defines a single port type, <code>Greeter</code>, with a SOAP binding,
<code>Greeter_SOAPBinding</code>, and a service, <code>SOAPService</code>,
which has a single port, <code>SoapPort</code>.</p><p><span
class="confluence-anchor-link"
id="DevelopingaConsumer-Example1"></span></p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>HelloWorld WSDL Contract</b></div><div
class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;"><wsdl:definitions name="HelloWorld"
targetNamespace="http://apache.org/hello_world_soap_http"
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><wsdl:definitions name="HelloWorld"
targetNamespace="http://apache.org/hello_world_soap_http"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://apache.org/hello_world_soap_http"
@@ -290,7 +290,7 @@ Apache CXF -- Developing a Consumer
</code> target namespace. All of the WSDL entities defined in this target
namespace (for example, the Greeter port type and the SOAPService service) map
to Java classes in the corresponding Java
package.</li><li><code>org.apache.hello_world_soap_http.types</code> <br
clear="none"> This package name is generated from the <code>
<a shape="rect" class="external-link"
href="http://apache.org/hello_world_soap_http/types">http://apache.org/hello_world_soap_http/types</a>
</code> target namespace. All of the XML types defined in this target
namespace (that is, everything defined in the <code>wsdl:types</code> element
of the HelloWorld contract) map to Java classes in the corresponding Java
package.</li></ul><p>The stub files generated by the wsdl2java command fall
into the following categories:</p><ul><li>Classes representing WSDL entities
(in the <code>org.apache.hello_world_soap_http</code> package) - the following
classes are generated to represent WSDL entities:<ul><li><code>Greeter</code>
is a Java interface that represents the Greeter WSDL port type. In JAX-WS
terminology, this Java interface is a service endpoint
interface.</li><li><code>SOAPService</code> is a Java class that represents the
SOAPService WSDL <code>service</code> element.</li><li><code>PingMeFault</code>
is a Java exception class (extending <code>java.lang.Exception</code>) that
represents the pingMeFault WSDL <code>fault</code>
element.</li></ul></li><li>Classes representi
ng XML types (in the <code>org.apache.hello_world_soap_http.types</code>
package) - in the HelloWorld example, the only generated types are the various
wrappers for the request and reply messages. Some of these data types are
useful for the<br clear="none"> asynchronous invocation model.</li></ul><h2
id="DevelopingaConsumer-ImplementingaCXFClient">Implementing a CXF
Client</h2><p>This section describes how to write the code for a simple Java
client, based on the WSDL contract <a shape="rect"
href="developing-a-consumer.html">above</a>. To implement the client, you need
to use the following stub classes:</p><ul><li>Service class (that is,
<code>SOAPService</code>).</li><li>Service endpoint interface (that is,
<code>Greeter</code>).</li></ul><h4
id="DevelopingaConsumer-Generatedserviceclass">Generated service
class</h4><p>The below shows the typical outline for a generated service class,
<code>ServiceName</code>, which extends the <code>javax.xml.ws.Service</code>
base class.</p><p><s
pan class="confluence-anchor-link"
id="DevelopingaConsumer-Example2"></span></p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Outline of a Generated Service
Class</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">public class ServiceName extends javax.xml.ws.Service
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public class ServiceName extends javax.xml.ws.Service
{
...
public ServiceName(URL wsdlLocation, QName serviceName) { }
@@ -306,7 +306,7 @@ Apache CXF -- Developing a Consumer
</div></div><p>The <code>ServiceName</code> class defines the following
methods:</p><ul><li>Constructor methods - the following forms of constructor
are defined:<ul><li><code>
<em>ServiceName</em>(URL <em>wsdlLocation</em>, QName
<em>serviceName</em>)</code> constructs a service object based on the data in
the <em>serviceName</em> service in the WSDL contract that is obtainable from
<em>wsdlLocation</em>.</li><li><code>
<em>ServiceName</em>()</code> is the default constructor, which
constructs a service object based on the service name and WSDL contract that
were provided at the time the stub code was generated (for example, when
running the CXF wsdl2java command). Using this constructor presupposes that the
WSDL contract remains available at its original
location.</li></ul></li><li><code>get_PortName_()</code> methods - for every
<em>PortName</em> port defined on the <em>ServiceName</em> service, CXF
generates a corresponding <code>get_PortName_()</code> method in Java.
Therefore, a <code>wsdl:service</code> element that defines multiple ports will
generate a service class with multiple <code>get_PortName_()</code>
methods.</li></ul><h4 id="DevelopingaConsumer-Serviceendpointinterface">Service
endpoint interface</h4><p>For every port type defined in the original WSDL
contract, you can generate a corresponding service endpoint interface in Java.
A service endpoint interface is the Java ma
pping of a WSDL port type. Each operation defined in the original WSDL port
type maps to a corresponding method in the service endpoint interface. The
operation's parameters are mapped as follows:</p><ol><li>The input parameters
are mapped to method arguments.</li><li>The first output parameter is mapped to
a return value.</li><li>If there is more than one output parameter, the second
and subsequent output parameters map to method arguments (moreover, the values
of these arguments must be passed using Holder types).</li></ol><p>For example,
the below shows the Greeter service endpoint interface, which is generated from
the Greeter port type defined in <a shape="rect"
href="developing-a-consumer.html">#Example1</a>. For simplicity, <a
shape="rect" href="developing-a-consumer.html">#Example3</a> omits the standard
JAXB and JAX-WS annotations.</p><p><span class="confluence-anchor-link"
id="DevelopingaConsumer-Example3"></span></p><div class="code panel pdl"
style="border-width: 1px;"><
div class="codeHeader panelHeader pdl" style="border-bottom-width:
1px;"><b>The Greeter Service Endpoint Interface</b></div><div
class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">/* Generated by WSDLToJava Compiler. */
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">/* Generated by WSDLToJava Compiler. */
package org.objectweb.hello_world_soap_http;
...
@@ -322,7 +322,7 @@ public interface Greeter
}
</pre>
</div></div><h4 id="DevelopingaConsumer-Clientmainfunction">Client main
function</h4><p>Here is Java code that implements the HelloWorld client. In
summary, the client connects to the <code>SoapPort</code> port on the
<code>SOAPService</code> service and then proceeds to invoke each of the
operations supported by the <code>Greeter</code> port type.</p><p><span
class="confluence-anchor-link"
id="DevelopingaConsumer-Example4"></span></p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Client Implementation Code</b></div><div
class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">package demo.hw.client;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package demo.hw.client;
import java.io.File;
import java.net.URL;
@@ -392,10 +392,10 @@ public final class Client {
}
</pre>
</div></div><p>The <code>Client.main()</code> function proceeds as
follows:</p><ol><li>The CXF runtime is implicitly initialized - that is,
provided the CXF runtime classes are loaded. Hence, there is no need to call a
special function in order to initialize CXF.</li><li>The client expects a
single string argument that gives the location of the WSDL contract for
HelloWorld. The WSDL location is stored in <code>wsdlURL</code>.</li><li><p>A
new port object (which enables you to access the remote server endpoint) is
created in two steps, as shown in the following code fragment:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
Greeter port = ss.getSoapPort();</pre>
</div></div><p>To create a new port object, you first create a service object
(passing in the WSDL location and service name) and then call the appropriate
<code>get <em>PortName</em> ()</code> method to obtain an instance of the
particular port you need. In this case, the <code>SOAPService</code> service
supports only the <code>SoapPort</code> port, which is of <code>Greeter</code>
type.</p></li><li>The client proceeds to call each of the methods supported by
the <code>Greeter</code> service endpoint interface.</li><li>In the case of the
<code>pingMe()</code> operation, the example code shows how to catch the
<code>PingMeFault</code> fault exception.</li></ol><h2
id="DevelopingaConsumer-SettingConnectionPropertieswithContexts">Setting
Connection Properties with Contexts</h2><p>You can use JAX-WS contexts to
customize the properties of a client proxy. In particular, contexts can be used
to modify connection properties and to send data in protocol headers. For
example, you could use
contexts to add a SOAP header, either to a request message or to a response
message. The following types of context are supported on the client
side:</p><ul><li><strong>Request context</strong> - on the client side, the
request context enables you to set properties that affect outbound messages.
Request context properties are applied to a specific port instance and, once
set, the properties affect every subsequent operation invocation made on the
port, until such time as a property is explicitly cleared. For example, you
might use a request context property to set a connection timeout or to
initialize data for sending in a header.</li><li><strong>Response
context</strong> - on the client side, you can access the response context to
read the property values set by the inbound message from the last operation
invocation. Response context properties are reset after every operation
invocation. For example, you might access a response context property to read
header information received f
rom the last inbound message.</li></ul><h4
id="DevelopingaConsumer-Settingarequestcontext">Setting a request
context</h4><p>To set a particular request context property,
<em>ContextPropertyName</em>, to the value, <em>PropertyValue</em>, use the
code shown here:</p><p><span class="confluence-anchor-link"
id="DevelopingaConsumer-Example4"></span></p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Setting a Request Context Property on the
Client Side</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">// Set request context property.
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">// Set request context property.
java.util.Map<String, Object> requestContext =
((javax.xml.ws.BindingProvider)port).getRequestContext();
requestContext.put(ContextPropertyName, PropertyValue);
@@ -404,7 +404,7 @@ requestContext.put(ContextPropertyName,
port.SomeOperation();
</pre>
</div></div><p>You have to cast the port object to
<code>javax.xml.ws.BindingProvider</code> in order to access the request
context. The request context itself is of type, <code>java.util.Map<String,
Object></code>, which is a hash map that has keys of <code>String</code> and
values of arbitrary type. Use <code>java.util.Map.put()</code> to create a new
entry in the hash map.</p><h4
id="DevelopingaConsumer-Readingaresponsecontext">Reading a response
context</h4><p>To retrieve a particular response context property,
<em>ContextPropertyName</em>, use the code shown here:</p><p><span
class="confluence-anchor-link"
id="DevelopingaConsumer-Example5"></span></p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Reading a Response Context Property on the
Client Side</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">// Invoke an operation.
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">// Invoke an operation.
port.SomeOperation();
// Read response context property.
@@ -413,7 +413,7 @@ java.util.Map<String, Object> resp
PropertyType propValue = (PropertyType)
responseContext.get(ContextPropertyName);
</pre>
</div></div><p>The response context is of type, <code>java.util.Map<String,
Object></code>, which is a hash map that has keys of type
<code>String</code> and values of an arbitrary type. Use
<code>java.util.Map.get()</code> to access an entry in the hash map of response
context properties.</p><h4 id="DevelopingaConsumer-Supportedcontexts">Supported
contexts</h4><p>CXF supports the following context properties:</p><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Context Property Name</p></th><th
colspan="1" rowspan="1" class="confluenceTh"><p>Context Property
Type</p></th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>org.apache.cxf.ws.addressing.JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES</code></p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>org.apache.cxf.ws.addressing.AddressingProperties</code></p></td></tr></tbody></table></div><h2
id="DevelopingaConsumer-Asynchrono
usInvocationModel">Asynchronous Invocation Model</h2><p>In addition to the
usual synchronous mode of invocation, CXF also supports two forms of
asynchronous invocation, as follows:</p><ul><li><strong>Polling
approach</strong> - in this case, to invoke the remote operation, you call a
special method that has no output parameters, but returns a
<code>javax.xml.ws.Response</code> instance. The <code>Response</code> object
(which inherits from the <code>javax.util.concurrency.Future</code> interface)
can be polled to check whether or not a response message has
arrived.</li><li><strong>Callback approach</strong> - in this case, to invoke
the remote operation, you call another special method that takes a reference to
a callback object (of <code>javax.xml.ws.AsyncHandler</code> type) as one of
its parameters. Whenever the response message arrives at the client, the CXF
runtime calls back on the <code>AsyncHandler</code> object to give it the
contents of the response message.</li></ul><p>Bo
th of these asynchronous invocation approaches are described here and
illustrated by code examples.</p><h4
id="DevelopingaConsumer-Contractforasynchronousexample">Contract for
asynchronous example</h4><p>The following example shows the WSDL contract that
is used for the asynchronous example. The contract defines a single port type,
<code>GreeterAsync</code>, which contains a single operation,
<code>greetMeSometime</code>.</p><p><span class="confluence-anchor-link"
id="DevelopingaConsumer-Example6"></span></p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>HelloWorld WSDL Contract for Asynchronous
Example</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;"><wsdl:definitions
xmlns="http://schemas.xmlsoap.org/wsdl/"
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><wsdl:definitions
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://apache.org/hello_world_async_soap_http"
xmlns:x1="http://apache.org/hello_world_async_soap_http/types"
@@ -479,7 +479,7 @@ PropertyType propValue = (PropertyType)
</div></div><h4
id="DevelopingaConsumer-Generatingtheasynchronousstubcode">Generating the
asynchronous stub code</h4><p>The asynchronous style of invocation requires
extra stub code (for example, dedicated asychronous methods defined on the
service endpoint interface). This special stub code is not generated by
default, however. To switch on the asynchronous feature and generate the
requisite stub code, you must use the mapping customization feature from the
WSDL 2.0 specification.</p><p>Customization enables you to modify the way the
wsdl2java utility generates stub code. In particular, it enables you to modify
the WSDL-to-Java mapping and to switch on certain features. Here, customization
is used to switch on the asynchronous invocation feature. Customizations are
specified using a binding declaration, which you define using a
<code>jaxws:bindings</code> tag (where the jaxws prefix is tied to the <code>
<a shape="rect" class="external-link"
href="http://java.sun.com/xml/ns/jaxws"
rel="nofollow">http://java.sun.com/xml/ns/jaxws</a>
</code> namespace). There are two alternative ways of specifying a binding
declaration:</p><ul><li><strong>External binding declaration</strong> - the
<code>jaxws:bindings</code> element is defined in a file separately from the
WSDL contract. You specify the location of the binding declaration file to the
wsdl2java utility when you generate the stub code.</li><li><strong>Embedded
binding declaration</strong> - you can also embed the
<code>jaxws:bindings</code> element directly in a WSDL contract, treating it as
a WSDL extension. In this case, the settings in <code>jaxws:bindings</code>
apply only to the immediate parent element.</li></ul><p>This section considers
only the first approach, the external binding declaration. The template for a
binding declaration file that switches on asynchronous invocations is shown
next:</p><p><span class="confluence-anchor-link"
id="DevelopingaConsumer-Example7"></span></p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHead
er panelHeader pdl" style="border-bottom-width: 1px;"><b>Template for an
Asynchronous Binding Declaration</b></div><div class="codeContent panelContent
pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;"><bindings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><bindings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
wsdlLocation="<at:var at:name="WSDL_LOCATION"
/>/hello_world_async.wsdl"
xmlns="http://java.sun.com/xml/ns/jaxws">
@@ -491,7 +491,7 @@ PropertyType propValue = (PropertyType)
</div></div><p>Where <em>AffectedWSDLContract</em> specifies the URL of the
WSDL contract that is affected by this binding declaration. The
<em>AffectedNode</em> is an XPath value that specifies which node (or nodes)
from the WSDL contract are affected by this binding declaration. You can set
<em>AffectedNode</em> to <code>wsdl:definitions</code>, if you want the entire
WSDL contract to be affected. The {jaxws:enableAsyncMapping}} element is set to
<code>true</code> to enable the asynchronous invocation feature.</p><p>For
example, if you want to generate asynchronous methods only for the
<code>GreeterAsync</code> port type, you could specify <code><bindings
node="wsdl:definitions/wsdl:portType<a shape="rect" class="unresolved"
href="#">@name='GreeterAsync'</a>"></code> in the preceding binding
declaration.</p><p>Assuming that the binding declaration is stored in a file,
<code>async_binding.xml</code>, you can generate the requisite stub files with
asynchronous support by enter
ing the following wsdl2java command:</p><div class="panel"
style="border-width: 1px;"><div class="panelContent">
<p><code>wsdl2java -ant -client -d ClientDir -b async_binding.xml
hello_world.wsdl</code></p>
</div></div><p>When you run the wsdl2java command, you specify the location of
the binding declaration file using the -b option. After generating the stub
code in this way, the <code>GreeterAsync</code> service endpoint interface (in
the file <code>GreeterAsync.java</code>) is defined as shown below:</p><p><span
class="confluence-anchor-link"
id="DevelopingaConsumer-Example8"></span></p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Service Endpoint Interface with Methods
for Asynchronous Invocations</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">/* Generated by WSDLToJava Compiler. */
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">/* Generated by WSDLToJava Compiler. */
package org.apache.hello_world_async_soap_http;
...
import java.util.concurrent.Future;
@@ -514,7 +514,7 @@ public interface GreeterAsync {
}
</pre>
</div></div><p>In addition to the usual synchronous method,
<code>greetMeSometime()</code>, two asynchronous methods are also generated for
the <code>greetMeSometime</code> operation, as
follows:</p><ul><li><code>greetMeSometimeAsync()</code> method with
<code>Future<?></code> return type and an extra
<code>javax.xml.ws.AsyncHandler</code> parameter - call this method for the
callback approach to asynchronous
invocation.</li><li><code>greetMeSometimeAsync()</code> method with
<code>Response<GreetMeSometimeResponse></code> return type - call this
method for the polling approach to asynchronous invocation.</li></ul><p>The
details of the callback approach and the polling approach are discussed in the
following subsections.</p><h4
id="DevelopingaConsumer-Implementinganasynchronousclientwiththepollingapproach">Implementing
an asynchronous client with the polling approach</h4><p>The below sample
illustrates the polling approach to making an asynchronous operation call.
Using t
his approach, the client invokes the<br clear="none"> operation by calling the
special Java method, <code>_OperationName_Async()</code>, that returns a
<code>javax.xml.ws.Response<T></code> object, where T is the type of the
operation's response message. The <code>Response<T></code> object can be
polled at a later stage to check whether the operation's response message has
arrived.</p><p><span class="confluence-anchor-link"
id="DevelopingaConsumer-Example9"></span></p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Polling Approach for an Asynchronous
Operation Call</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">package demo.hw.client;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package demo.hw.client;
import java.io.File;
import java.util.concurrent.Future;
@@ -548,14 +548,14 @@ public final class Client {
}
</pre>
</div></div><p>The <code>greetMeSometimeAsync()</code> method invokes the
<code>greetMeSometimes</code> operation, transmitting the input parameters to
the remote service and returning a reference to a
<code>javax.xml.ws.Response<GreetMeSometimeResponse></code> object. The
<code>Response</code> class is defined by extending the standard
<code>java.util.concurrency.Future<T></code> interface, which is
specifically designed for polling the outcome of work performed by a concurrent
thread. There are essentially two basic approaches to polling using the
<code>Response</code> object:</p><ul><li><p><strong>Non-blocking
polling</strong> - before attempting to get the result, check whether the
response has arrived by calling the non-blocking<br clear="none">
<code>Response<T>.isDone()</code> method. For example:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">Response<GreetMeSometimeResponse>
greetMeSomeTimeResp = ...;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">Response<GreetMeSometimeResponse>
greetMeSomeTimeResp = ...;
if (greetMeSomeTimeResp.isDone()) {
GreetMeSometimeResponse reply = greetMeSomeTimeResp.get();
}
</pre>
</div></div></li><li><p><strong>Blocking polling</strong> - call
<code>Response<T>.get()</code> right away and block until the response
arrives (optionally specifying a timeout). For example, to poll for a response,
with a 60 second timeout:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">Response<GreetMeSometimeResponse>
greetMeSomeTimeResp = ...;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">Response<GreetMeSometimeResponse>
greetMeSomeTimeResp = ...;
GreetMeSometimeResponse reply = greetMeSomeTimeResp.get(
60L,
@@ -563,7 +563,7 @@ GreetMeSometimeResponse reply = greetMeS
);
</pre>
</div></div></li></ul><h4
id="DevelopingaConsumer-Implementinganasynchronousclientwiththecallbackapproach">Implementing
an asynchronous client with the callback approach</h4><p>An alternative
approach to making an asynchronous operation invocation is to implement a
callback class, by deriving from the<br clear="none">
<code>javax.xml.ws.AsyncHandler</code> interface. This callback class must
implement a <code>handleResponse()</code> method, which is called by the CXF
runtime to notify the client that the response has arrived. The following shows
an outline of the <code>AsyncHandler</code> interface that you need to
implement.</p><p><span class="confluence-anchor-link"
id="DevelopingaConsumer-Example10"></span></p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>The javax.xml.ws.AsyncHandler
Interface</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">package javax.xml.ws;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package javax.xml.ws;
public interface AsyncHandler<T>
{
@@ -571,7 +571,7 @@ public interface AsyncHandler<T>
}
</pre>
</div></div><p>In this example, a callback class,
<code>TestAsyncHandler</code>, is defined as shown below.</p><p><span
class="confluence-anchor-link"
id="DevelopingaConsumer-Example11"></span></p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>The TestAsyncHandler Callback
Class</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">package demo.hw.client;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package demo.hw.client;
import javax.xml.ws.AsyncHandler;
import javax.xml.ws.Response;
@@ -595,7 +595,7 @@ public class TestAsyncHandler implements
}
</pre>
</div></div><p>The implementation of <code>handleResponse()</code> shown in <a
shape="rect" href="developing-a-consumer.html">#Example11</a> simply gets the
response data and stores it in a member variable, <code>reply</code>. The extra
<code>getResponse()</code> method is just a convenience method that extracts
the sole output parameter (that is, <code>responseType</code>) from the
response.</p><p><a shape="rect"
href="developing-a-consumer.html">#Example12</a> illustrates the callback
approach to making an asynchronous operation call. Using this approach, the
client invokes the operation by calling the special Java method,
<code>_OperationName_Async()</code>, that returns a
<code>java.util.concurrency.Future<?></code> object and takes an extra
parameter of <code>AsyncHandler<T></code>.</p><p><span
class="confluence-anchor-link"
id="DevelopingaConsumer-Example12"></span></p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl" st
yle="border-bottom-width: 1px;"><b>Callback Approach for an Asynchronous
Operation Call</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">package demo.hw.client;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package demo.hw.client;
import java.io.File;
import java.util.concurrent.Future;
Modified: websites/production/cxf/content/docs/developing-a-service.html
==============================================================================
--- websites/production/cxf/content/docs/developing-a-service.html (original)
+++ websites/production/cxf/content/docs/developing-a-service.html Wed Sep 13
15:05:52 2017
@@ -32,8 +32,8 @@
<link type="text/css" rel="stylesheet"
href="/resources/highlighter/styles/shThemeCXF.css">
<script src='/resources/highlighter/scripts/shCore.js'></script>
-<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script src='/resources/highlighter/scripts/shBrushBash.js'></script>
+<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script>
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
@@ -118,11 +118,11 @@ Apache CXF -- Developing a Service
<!-- Content -->
<div class="wiki-content">
<div id="ConfluenceContent"><style type="text/css">/*<![CDATA[*/
-div.rbtoc1505311235392 {padding: 0px;}
-div.rbtoc1505311235392 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1505311235392 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1505314908925 {padding: 0px;}
+div.rbtoc1505314908925 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1505314908925 li {margin-left: 0px;padding-left: 0px;}
-/*]]>*/</style><div class="toc-macro rbtoc1505311235392">
+/*]]>*/</style><div class="toc-macro rbtoc1505314908925">
<ul class="toc-indentation"><li><a shape="rect"
href="#DevelopingaService-DevelopingaServiceusingJAX-WS">Developing a Service
using JAX-WS</a>
<ul class="toc-indentation"><li><a shape="rect"
href="#DevelopingaService-WSDLFirstDevelopment">WSDL First Development</a>
<ul class="toc-indentation"><li><a shape="rect"
href="#DevelopingaService-GeneratingtheStartingPointCode">Generating the
Starting Point Code</a>
@@ -213,7 +213,7 @@ div.rbtoc1505311235392 li {margin-left:
<p><span class="confluence-anchor-link"
id="DevelopingaService-Example1"></span></p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>Implementation of the
Greeter Service</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
package demo.hw.server;
import org.apache.hello_world_soap_http.Greeter;
@@ -275,7 +275,7 @@ In this pattern, you typically have an e
<p><span class="confluence-anchor-link"
id="DevelopingaService-Example2"></span></p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>Simple SEI</b></div><div
class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
package org.apache.cxf;
public interface QuoteReporter
@@ -293,7 +293,7 @@ public interface QuoteReporter
<p><span class="confluence-anchor-link"
id="DevelopingaService-Example3"></span></p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>Implementation for
SEI</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
package org.apache.cxf;
import java.util.*;
@@ -341,7 +341,7 @@ public class StockQuoteReporter implemen
<p><span class="confluence-anchor-link"
id="DevelopingaService-Example4"></span></p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>Interface with the
@WebService Annotation</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
package com.mycompany.demo;
import javax.jws.*;
@@ -367,7 +367,7 @@ public interface QuoteReporter
<p><span class="confluence-anchor-link"
id="DevelopingaService-Example5"></span></p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>Annotated Service
Implementation Class</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
package org.apache.cxf;
import javax.jws.*;
@@ -410,7 +410,7 @@ public class StockQuoteReporter implemen
<p><span class="confluence-anchor-link"
id="DevelopingaService-Example6"></span></p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>Specifying an RPC/LITERAL
SOAP Binding</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
package org.eric.demo;
import javax.jws.*;
@@ -481,7 +481,7 @@ FixMe: <code>faultName</code> is defined
<p><span class="confluence-anchor-link"
id="DevelopingaService-Example7"></span></p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>SEI with Annotated
Methods</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
package org.apache.cxf;
import javax.jws.*;
@@ -526,7 +526,7 @@ public interface QuoteReporter
<p><span class="confluence-anchor-link"
id="DevelopingaService-Example8"></span></p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>Fully Annotated
SEI</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
package org.apache.cxf;
import javax.jws.*;
@@ -566,7 +566,7 @@ public interface QuoteReporter
<p><span class="confluence-anchor-link"
id="DevelopingaService-Example9"></span></p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>Generated WSDL from an
SEI</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://demo.eric.org/"
xmlns:tns="http://demo.eric.org/"
Modified: websites/production/cxf/content/docs/developing-assertions.html
==============================================================================
--- websites/production/cxf/content/docs/developing-assertions.html (original)
+++ websites/production/cxf/content/docs/developing-assertions.html Wed Sep 13
15:05:52 2017
@@ -32,9 +32,9 @@
<link type="text/css" rel="stylesheet"
href="/resources/highlighter/styles/shThemeCXF.css">
<script src='/resources/highlighter/scripts/shCore.js'></script>
-<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
-<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
<script src='/resources/highlighter/scripts/shBrushBash.js'></script>
+<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
+<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script>
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
@@ -157,7 +157,7 @@ Implementation of <em>build()</em> metho
<p>This is the easiest way of providing runtime support for an Assertion.
Steps 1. and 2. listed in <a shape="rect"
href="ws-policy-framework-overview.html">Interaction with the Framework</a> can
usually be coded as follows:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
package mycompany.com.interceptors;
import org.apache.cxf.ws.policy.AssertionInfoMap;
@@ -191,7 +191,7 @@ class MyPolicyAwareInterceptor {
<p>Sometimes, it may be more convenient to spead the above functionality
accross several interceptors, possibly according to chain (in, in fault, out,
outfault). In any case, you need to also provide a PolicyInterceptorProvider,
and declare a corresponding bean. Either implement one from scratch or use the
PolicyInterceptorProviderImpl in the api package and customise it as follows
(assuming that one and the same interceptor is used for all paths). The main
task of policy interceptor provider is to say which interceptors must be
activated for specified policy assertion:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
<bean name="MyPolicyAwareInterceptor"
class="mycompany.com.interceptors.MyPolicyAwareInterceptor"/>
@@ -236,7 +236,7 @@ class MyPolicyAwareInterceptor {
<p>It is also possible to implement policy interceptor provider
programmatically from scratch. It's constructor gives assertions QNames as
argument of super constructor and adds corresponded interceptors using
getters:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
public class MyInterceptorProvider extends AbstractPolicyInterceptorProvider {
private static final long serialVersionUID = -5248428637449096540L;
private static final MyInInterceptor IN_INTERCEPTOR = new
MyInInterceptor();
@@ -261,7 +261,7 @@ public class MyInterceptorProvider exten
<p>Since version 2.5.2, Assertion builder and policy interceptor provider can
be registered using CXF bus extension mechanism: just create a file
META-INF/cxf/bus-extensions.txt containing the following:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
org.company.MyInterceptorProvider::true
org.company.MyAssertionBuilder::true
</pre>
@@ -275,7 +275,7 @@ Since CXF 2.6.0 it is possible to regist
<h3 id="DevelopingAssertions-Initialisation">Initialisation</h3>
<p>Conduits/Destinations have access to the EndpointInfo object in their their
constructors,. Assuming they also have access to the bus, they can at any time
in their lifecycle obtain the effective policy for the endpoint as follows:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
class MyPolicyAwareConduit {
static final QName assertionType = new QName("http://mycompany.com}",
"MyType"});
@@ -308,7 +308,7 @@ class MyPolicyAwareConduit {
HTTPConduit is an exmaple of a policy aware Conduit. It supports assertions of
type HTTPClientPolicy, which are represented in the runtime as
JaxbAssertion<HTTPClientPolicy> objects. HTTPConduit also has a data
member of type HTTPClientPolicy. It implements assertMessage as follows: for
outbound messages, it asserts all JaxbAssertion<HTTPClientPolicy> that
are compatible with this data member. For inboun d messages, all
HTTPClientPolicy assertions are asserted regardless their attributes. The
rationale for this is that the sematics of the HTTPClientPolicy assertion
effectively does not mandate any specific action on the inbound message.<br
clear="none">
Similary, on its inbound path, the HTTPDestination asserts all
HTTPServerPolicy assertions that are equal to the HTTPServerPolicy assertion
configured for the destination, and all assertions of that type on the outbound
path.</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
class MyPolicyAwareConduit implements Assertor {
static final QName MYTYPE = new QName("http://mycompany.com}",
"MyType"});
Modified: websites/production/cxf/content/docs/dynamic-clients.html
==============================================================================
--- websites/production/cxf/content/docs/dynamic-clients.html (original)
+++ websites/production/cxf/content/docs/dynamic-clients.html Wed Sep 13
15:05:52 2017
@@ -128,7 +128,7 @@ Apache CXF -- Dynamic Clients
<p>Let's pretend for a moment that you have a WSDL which defines a single
operation "echo" which takes an input of a string and outputs a String. You
could use the JaxWsDynamicClientFactory for it like this:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient("echo.wsdl");
@@ -138,7 +138,7 @@ System.out.println("Echo response: " + r
</div></div>
<p>Many WSDLs will have more complex types though. In this case the
JaxWsDynamicClientFactory takes care of generating Java classes for these
types. For example, we may have a People service which keeps track of people in
an organization. In the sample below we create a Person object that was
generated for us dynamically and send it to the server using the addPerson
operation:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient("people.wsdl", classLoader);
Modified: websites/production/cxf/content/docs/embedding-cxf-inside-spring.html
==============================================================================
--- websites/production/cxf/content/docs/embedding-cxf-inside-spring.html
(original)
+++ websites/production/cxf/content/docs/embedding-cxf-inside-spring.html Wed
Sep 13 15:05:52 2017
@@ -117,7 +117,7 @@ Apache CXF -- Embedding CXF inside Sprin
<!-- Content -->
<div class="wiki-content">
<div id="ConfluenceContent"><div class="confluence-information-macro
confluence-information-macro-note"><p class="title">Changes in CXF
2.4.x</p><span class="aui-icon aui-icon-small aui-iconfont-warning
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p><strong>The below is applicable
for CXF versions 2.3.x and older.</strong> Starting in CXF 2.4.0, the
extensions are loaded internally by CXF automatically and you do not need to
import all the cxf-extension-*.xml file. You only need to import
classpath:META-INF/cxf/cxf.xml.</p></div></div><p>You can embed CXF within an
existing Spring application. Since all XML configuration files are Spring xml
files, the two approaches should be equivalent.</p><p>CXF includes Spring
configuration files which configure the various CXF modules. You will want to
import these into your application. Here is an example that imports the core
CXF components, the SOAP binding, and the servlet transport:</p><div clas
s="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;"><beans
xmlns="http://www.springframework.org/schema/beans"
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
@@ -131,7 +131,7 @@ http://cxf.apache.org/jaxws http://cxf.a
</beans>
</pre>
</div></div><p>To include all the CXF modules you can use cxf-all or a
wildcard expression:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;"><beans
xmlns="http://www.springframework.org/schema/beans"
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
Modified: websites/production/cxf/content/docs/failoverfeature.html
==============================================================================
--- websites/production/cxf/content/docs/failoverfeature.html (original)
+++ websites/production/cxf/content/docs/failoverfeature.html Wed Sep 13
15:05:52 2017
@@ -117,14 +117,14 @@ Apache CXF -- FailoverFeature
<!-- Content -->
<div class="wiki-content">
<div id="ConfluenceContent"><h1
id="FailoverFeature-FailoverandLoadDistributorFeature">Failover and Load
Distributor Feature</h1><p><style type="text/css">/*<![CDATA[*/
-div.rbtoc1505311252213 {padding: 0px;}
-div.rbtoc1505311252213 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1505311252213 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1505314874072 {padding: 0px;}
+div.rbtoc1505314874072 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1505314874072 li {margin-left: 0px;padding-left: 0px;}
-/*]]>*/</style></p><div class="toc-macro rbtoc1505311252213">
+/*]]>*/</style></p><div class="toc-macro rbtoc1505314874072">
<ul class="toc-indentation"><li><a shape="rect"
href="#FailoverFeature-FailoverandLoadDistributorFeature">Failover and Load
Distributor Feature</a></li><li><a shape="rect"
href="#FailoverFeature-Failover">Failover</a></li><li><a shape="rect"
href="#FailoverFeature-CircuitBreakersFailover">Circuit Breakers
Failover</a></li><li><a shape="rect"
href="#FailoverFeature-LoadDistribution">Load Distribution</a></li><li><a
shape="rect" href="#FailoverFeature-ConfiguringJAX-RSclients">Configuring
JAX-RS clients</a></li></ul>
</div><h1 id="FailoverFeature-Failover">Failover</h1><p>The CXF Failover
feature allows to configure CXF frontend clients to retry a call when the
target endpoint becomes unavailable.<br clear="none"> A number of retry
strategies available: a client can iterate sequentially over the alternative
addresses or chose them randomly. <br clear="none"> Every strategy can be
configured to do a delay between selecting the addresses.</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;"><beans
xmlns="http://www.springframework.org/schema/beans"
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:clustering="http://cxf.apache.org/clustering"
@@ -183,7 +183,7 @@ http://www.springframework.org/schema/ut
</beans>
</pre>
</div></div><p>Note, org.apache.cxf.clustering.RetryStrategy can be used to
retry the same, last address for a limited number of times, before switching to
the next address. Use RetryStrategy 'maxNumberOfRetries' property.
RetryStrategy currently uses a sequential algorithm for selecting the
addresses.</p><h1 id="FailoverFeature-CircuitBreakersFailover">Circuit Breakers
Failover</h1><p>The recent addition to CXF failover features is the
implementation based on circuit breakers, more precisely Apache Zest (<a
shape="rect" class="external-link"
href="https://zest.apache.org/">https://zest.apache.org/</a>) library. The
configuration is very similar to the regular failover strategy, the only
difference is usage of<strong> clustering:circuit-breaker-failover</strong>
element.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;"><beans
xmlns="http://www.springframework.org/schema/beans"
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:clustering="http://cxf.apache.org/clustering"
@@ -241,7 +241,7 @@ http://www.springframework.org/schema/ut
</beans></pre>
</div></div><p>Circuit breakers have recommended themselves as a proven
strategy to handle and monitor the failures related to external service calls,
giving the external systems a time to recover by preventing endless retries or
time-outing. For that reason, two configuration parameters could be
tuned:</p><ul style="list-style-type: square;"><li><strong>threshold</strong>:
the error threshold to open the circuit
breaker</li><li><strong>timeout</strong>: the timeout to wait before trying the
next invocation</li></ul><h1 id="FailoverFeature-LoadDistribution">Load
Distribution</h1><p>Load Distributor Feature is a Failover feature which can
allow the clients to iterate over alternative addresses on every new call,
irrespectively of whether the last call has reached its target or not. It can
help with the controlling the traffic originating from CXF clients at
individual servers.</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;"><beans
xmlns="http://www.springframework.org/schema/beans"
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:clustering="http://cxf.apache.org/clustering"
Modified: websites/production/cxf/content/docs/features.html
==============================================================================
--- websites/production/cxf/content/docs/features.html (original)
+++ websites/production/cxf/content/docs/features.html Wed Sep 13 15:05:52 2017
@@ -32,8 +32,8 @@
<link type="text/css" rel="stylesheet"
href="/resources/highlighter/styles/shThemeCXF.css">
<script src='/resources/highlighter/scripts/shCore.js'></script>
-<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
+<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script>
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
@@ -118,7 +118,7 @@ Apache CXF -- Features
<!-- Content -->
<div class="wiki-content">
<div id="ConfluenceContent"><h1 id="Features-FeaturesinCXF">Features in
CXF</h1><p>A Feature in CXF is a way of adding capabilities to a Server, Client
or Bus. For example, you could add the ability to log messages for each of
these objects, by configuring them with a LoggingFeature. To implement a
Feature, you must subclass AbstractFeature below. By default the initialize
methods all delegate to initializeProvider(InterceptorProvider), so if you're
simply adding interceptors to a Server, Client, or Bus, this allows you to add
them easily.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">public abstract class AbstractFeature {
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public abstract class AbstractFeature {
public void initialize(Server server, Bus bus) {
initializeProvider(server.getEndpoint(), bus);
}
@@ -159,7 +159,7 @@ Apache CXF -- Features
</pre>
</div></div><h1 id="Features-WritingandconfiguringtheFeature">Writing and
configuring the Feature</h1><p>CXF provides several features to configure
commonly used capabilities, such as logging, failover, policies, addressing,
and reliable messaging. You can go to the <a shape="rect"
href="featureslist.html">FeaturesList</a> for more information.</p><h2
id="Features-WritingaFeature">Writing a Feature</h2><p>It is very easy to write
a new feature; your feature just needs to extends the AbstractFeature and
implement initializeProvider or write customizing code for configuring client
or server interceptors. Here is an example for implementing the logging
feature.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">public class LoggingFeature extends AbstractFeature {
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public class LoggingFeature extends AbstractFeature {
private static final int DEFAULT_LIMIT = 100 * 1024;
private static final LoggingInInterceptor IN = new
LoggingInInterceptor(DEFAULT_LIMIT);
private static final LoggingOutInterceptor OUT = new
LoggingOutInterceptor(DEFAULT_LIMIT);
@@ -201,7 +201,7 @@ Apache CXF -- Features
}
</pre>
</div></div><h2 id="Features-AddingaFeatureprogrammatically">Adding a Feature
programmatically</h2><p>To add the feature to both server and client, you can
use the Feature annotation on the service class</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;"> @org.apache.cxf.feature.Features (features =
"org.apache.cxf.jaxws.service.AnnotationFeature")
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"> @org.apache.cxf.feature.Features (features =
"org.apache.cxf.jaxws.service.AnnotationFeature")
public class HelloServiceImpl implements HelloService {
public String sayHi() {
return "HI";
@@ -210,7 +210,7 @@ Apache CXF -- Features
</pre>
</div></div><p>You can also add the feature to the server by using
ServerFactoryBean, or the client by using the ClientFactoryBean</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">import org.apache.cxf.frontend.ServerFactoryBean;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">import org.apache.cxf.frontend.ServerFactoryBean;
import org.apache.cxf.frontend.ClientFactoryBean;
...
ServerFactoryBean serverFactoryBean = new ServerFactoryBean();
@@ -225,7 +225,7 @@ clientFactoryBean.setFeatures(new ArrayL
</pre>
</div></div><h2 id="Features-AddingaFeaturethroughconfiguration">Adding a
Feature through configuration</h2><p>Here are some examples on using
configuration files to add features. You can find more information about the
CXF provides features at <a shape="rect"
href="featureslist.html">FeaturesList</a>.</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;"><beans
xmlns="http://www.springframework.org/schema/beans"
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:jaxws="http://cxf.apache.org/jaxws"
Modified: websites/production/cxf/content/docs/general-cxf-logging.html
==============================================================================
--- websites/production/cxf/content/docs/general-cxf-logging.html (original)
+++ websites/production/cxf/content/docs/general-cxf-logging.html Wed Sep 13
15:05:52 2017
@@ -32,9 +32,9 @@
<link type="text/css" rel="stylesheet"
href="/resources/highlighter/styles/shThemeCXF.css">
<script src='/resources/highlighter/scripts/shCore.js'></script>
-<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
-<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
<script src='/resources/highlighter/scripts/shBrushBash.js'></script>
+<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
+<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script>
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
@@ -119,11 +119,11 @@ Apache CXF -- General CXF Logging
<!-- Content -->
<div class="wiki-content">
<div id="ConfluenceContent"><h1
id="GeneralCXFLogging-Configuringlogginglevels">Configuring logging
levels</h1><p>In the <a shape="rect" class="external-link"
href="http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/etc/">/etc
folder</a> of the CXF distribution there is a sample Java SE
logging.properties file you can use to configure logging. For example, if you
want to change the console logging level from WARNING to FINE, you need to
update two properties in this logging.properties file as below:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">.level= FINE
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">.level= FINE
java.util.logging.ConsoleHandler.level = FINE
</pre>
</div></div><p>Once this is done, you will need to set the
<strong>-Djava.util.logging.config.file</strong> property to the location of
the logging.properties file. As an example, the Ant target below has this
property set:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;"><target name="runClient">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;"><target name="runClient">
<java classname="client.WSClient" fork="true">
<classpath>
<pathelement location="${build.classes.dir}"/>
@@ -136,13 +136,13 @@ java.util.logging.ConsoleHandler.level =
</target>
</pre>
</div></div><p>Alternatively, for SOAP clients, you can modify the Java-wide
logging.properties file in the JDK_HOME/jre/lib folder, or for servlet-hosted
web service providers, placing a logging.properties file in the WEB-INF/classes
folder (see <a shape="rect" class="external-link"
href="http://tomcat.apache.org/tomcat-8.0-doc/logging.html">here</a> for more
details.)</p><h2
id="GeneralCXFLogging-UsingLog4jInsteadofjava.util.logging">Using Log4j Instead
of java.util.logging</h2><p>As noted above, CXF uses the
<code>java.util.logging</code> package ("Java SE Logging") by default. But it
is possible to switch CXF to instead use <a shape="rect" class="external-link"
href="http://logging.apache.org/log4j/">Log4J</a>. This is achieved through the
use of configuration files. There are two options to bootstrapping CXF logging
and each is listed below:</p><ul><li>Add the following system property to the
classpath from which CXF is initialized:</li></ul><div class="code panel pdl"
style="b
order-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">-Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">-Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger
</pre>
</div></div><ul><li>Add the file
<code>META-INF/cxf/org.apache.cxf.Logger</code> to the classpath and make sure
it contains the following content:</li></ul><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">org.apache.cxf.common.logging.Log4jLogger
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">org.apache.cxf.common.logging.Log4jLogger
</pre>
</div></div><h2
id="GeneralCXFLogging-UsingSLF4JInsteadofjava.util.logging(since2.2.8)">Using
SLF4J Instead of java.util.logging (since 2.2.8)</h2><p>As noted above, CXF
uses the <code>java.util.logging</code> package by default. But it is possible
to switch CXF to instead use <a shape="rect" class="external-link"
href="http://www.slf4j.org/" rel="nofollow">SLF4J</a>. This is achieved through
the use of configuration files. There are two options to bootstrapping CXF
logging and each is listed below:</p><ul><li>Add the following system property
to the classpath from which CXF is initialized:</li></ul><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">-Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Slf4jLogger
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">-Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Slf4jLogger
</pre>
</div></div><ul><li>Add the file
<code>META-INF/cxf/org.apache.cxf.Logger</code> to the classpath and make sure
it contains the following
content:</li></ul><pre>org.apache.cxf.common.logging.Slf4jLogger
</pre></div>
Modified: websites/production/cxf/content/docs/generic-tracing-component.html
==============================================================================
--- websites/production/cxf/content/docs/generic-tracing-component.html
(original)
+++ websites/production/cxf/content/docs/generic-tracing-component.html Wed Sep
13 15:05:52 2017
@@ -129,13 +129,13 @@ The tracing should support a flow id tha
-<span class="gliffy-container" id="gliffy-container-25591961-2911"
data-fullwidth="1411" data-ceoid="25202745"
data-edit="${diagramEditLink.getLinkUrl()}"
data-full="${diagramZoomLink.getLinkUrl()}" data-filename="Tracing Component">
+<span class="gliffy-container" id="gliffy-container-25591961-7255"
data-fullwidth="1411" data-ceoid="25202745"
data-edit="${diagramEditLink.getLinkUrl()}"
data-full="${diagramZoomLink.getLinkUrl()}" data-filename="Tracing Component">
- <map id="gliffy-map-25591961-3646" name="gliffy-map-25591961-3646"></map>
+ <map id="gliffy-map-25591961-3405" name="gliffy-map-25591961-3405"></map>
- <img class="gliffy-image" id="gliffy-image-25591961-2911" width="1411"
height="510" data-full-width="1411" data-full-height="510"
src="https://cwiki.apache.org/confluence/download/attachments/25202745/Tracing%20Component.png?version=1&modificationDate=1298355725000&api=v2"
alt="Tracing Component" usemap="#gliffy-map-25591961-3646">
+ <img class="gliffy-image" id="gliffy-image-25591961-7255" width="1411"
height="510" data-full-width="1411" data-full-height="510"
src="https://cwiki.apache.org/confluence/download/attachments/25202745/Tracing%20Component.png?version=1&modificationDate=1298355725000&api=v2"
alt="Tracing Component" usemap="#gliffy-map-25591961-3405">
- <map class="gliffy-dynamic" id="gliffy-dynamic-map-25591961-2911"
name="gliffy-dynamic-map-25591961-2911"></map>
+ <map class="gliffy-dynamic" id="gliffy-dynamic-map-25591961-7255"
name="gliffy-dynamic-map-25591961-7255"></map>
</span>
@@ -146,13 +146,13 @@ The tracing should support a flow id tha
-<span class="gliffy-container" id="gliffy-container-25591966-5545"
data-fullwidth="565" data-ceoid="25202745"
data-edit="${diagramEditLink.getLinkUrl()}"
data-full="${diagramZoomLink.getLinkUrl()}" data-filename="Design Flow id">
+<span class="gliffy-container" id="gliffy-container-25591966-2774"
data-fullwidth="565" data-ceoid="25202745"
data-edit="${diagramEditLink.getLinkUrl()}"
data-full="${diagramZoomLink.getLinkUrl()}" data-filename="Design Flow id">
- <map id="gliffy-map-25591966-2515" name="gliffy-map-25591966-2515"></map>
+ <map id="gliffy-map-25591966-794" name="gliffy-map-25591966-794"></map>
- <img class="gliffy-image" id="gliffy-image-25591966-5545" width="565"
height="276" data-full-width="565" data-full-height="276"
src="https://cwiki.apache.org/confluence/download/attachments/25202745/Design%20Flow%20id.png?version=2&modificationDate=1298893753000&api=v2"
alt="Design Flow id" usemap="#gliffy-map-25591966-2515">
+ <img class="gliffy-image" id="gliffy-image-25591966-2774" width="565"
height="276" data-full-width="565" data-full-height="276"
src="https://cwiki.apache.org/confluence/download/attachments/25202745/Design%20Flow%20id.png?version=2&modificationDate=1298893753000&api=v2"
alt="Design Flow id" usemap="#gliffy-map-25591966-794">
- <map class="gliffy-dynamic" id="gliffy-dynamic-map-25591966-5545"
name="gliffy-dynamic-map-25591966-5545"></map>
+ <map class="gliffy-dynamic" id="gliffy-dynamic-map-25591966-2774"
name="gliffy-dynamic-map-25591966-2774"></map>
</span>
</div>
Modified: websites/production/cxf/content/docs/how-do-i-develop-a-client.html
==============================================================================
--- websites/production/cxf/content/docs/how-do-i-develop-a-client.html
(original)
+++ websites/production/cxf/content/docs/how-do-i-develop-a-client.html Wed Sep
13 15:05:52 2017
@@ -119,11 +119,11 @@ Apache CXF -- How do I develop a client?
<div id="ConfluenceContent"><p><br clear="none">
CXF provides you with many options to build clients for your services. This
guide is meant to give you a quick overview of those options and help you
orient yourself quickly with CXF.</p>
<style type="text/css">/*<![CDATA[*/
-div.rbtoc1505311190012 {padding: 0px;}
-div.rbtoc1505311190012 ul {list-style: disc;margin-left: 0px;padding-left:
20px;}
-div.rbtoc1505311190012 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1505314906128 {padding: 0px;}
+div.rbtoc1505314906128 ul {list-style: disc;margin-left: 0px;padding-left:
20px;}
+div.rbtoc1505314906128 li {margin-left: 0px;padding-left: 0px;}
-/*]]>*/</style><div class="toc-macro rbtoc1505311190012">
+/*]]>*/</style><div class="toc-macro rbtoc1505314906128">
<ul class="toc-indentation"><li><a shape="rect"
href="#HowdoIdevelopaclient?-BuildingClients">Building Clients</a>
<ul class="toc-indentation"><li><a shape="rect"
href="#HowdoIdevelopaclient?-WSDL2JavageneratedClient">WSDL2Java generated
Client</a></li><li><a shape="rect"
href="#HowdoIdevelopaclient?-JAX-WSProxy">JAX-WS Proxy</a></li><li><a
shape="rect" href="#HowdoIdevelopaclient?-JAX-WSDispatchAPIs">JAX-WS Dispatch
APIs</a></li><li><a shape="rect"
href="#HowdoIdevelopaclient?-SimpleFrontendClientProxy">Simple Frontend Client
Proxy</a></li><li><a shape="rect"
href="#HowdoIdevelopaclient?-DynamicClient">Dynamic Client</a></li></ul>
</li></ul>
@@ -136,7 +136,7 @@ div.rbtoc1505311190012 li {margin-left:
<p>One of the most common scenarios is that where you have a service which you
may or not manage and this service has a WSDL. In this case you'll often want
to generate a client from the WSDL. This provides you with a strongly typed
interface by which to interact with the service. Once you've generated a
client, typical usage of it will look like so:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
HelloService service = new HelloService();
Hello client = service.getHelloHttpPort();
@@ -154,7 +154,7 @@ String result = client.sayHi("Joe");
<p>Instead of using a wsdl2java-generated stub client directly, you can use
Service.create to create Service instances, the following code illustrates this
process:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
import java.net.URL;
import javax.xml.ws.Service;
...
@@ -171,7 +171,7 @@ String result = client.greetMe("test");
<p>JAX-WS provides the "dispatch" mechanism which makes it easy to dynamically
invoke services which you have not generated a client for. Using the Dispatch
mechanism you can create messages (which can be JAXB objects, Source objects,
or a SAAJMessage) and dispatch them to the server. A simple example might look
like this:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
import java.net.URL;
import javax.xml.transform.Source;
import javax.xml.ws.Dispatch;
@@ -200,7 +200,7 @@ Source response = disp.invoke(request);
<p>CXF includes a Client interface which allows you to invoke operations and
pass parameters for those operations. For instance:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
Client client = ....;
Object[] result = client.invoke("sayHi", "Dan");
</pre>
Modified: websites/production/cxf/content/docs/how-do-i-develop-a-service.html
==============================================================================
--- websites/production/cxf/content/docs/how-do-i-develop-a-service.html
(original)
+++ websites/production/cxf/content/docs/how-do-i-develop-a-service.html Wed
Sep 13 15:05:52 2017
@@ -117,14 +117,14 @@ Apache CXF -- How do I develop a service
<!-- Content -->
<div class="wiki-content">
<div id="ConfluenceContent"><p><br clear="none"> CXF provides you with many
options to build services. This guide is meant to give you a quick overview of
those options and help you orient yourself quickly with CXF.</p><p><style
type="text/css">/*<![CDATA[*/
-div.rbtoc1505311269072 {padding: 0px;}
-div.rbtoc1505311269072 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1505311269072 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1505314876471 {padding: 0px;}
+div.rbtoc1505314876471 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1505314876471 li {margin-left: 0px;padding-left: 0px;}
-/*]]>*/</style></p><div class="toc-macro rbtoc1505311269072">
+/*]]>*/</style></p><div class="toc-macro rbtoc1505314876471">
<ul class="toc-indentation"><li><a shape="rect"
href="#HowdoIdevelopaservice?-DifferentTypesOfServices">Different Types Of
Services</a></li><li><a shape="rect"
href="#HowdoIdevelopaservice?-JAX-WSAnnotatedServicesfromJava">JAX-WS Annotated
Services from Java</a></li><li><a shape="rect"
href="#HowdoIdevelopaservice?-JAX-WSAnnotatedServicesfromWSDL">JAX-WS Annotated
Services from WSDL</a></li><li><a shape="rect"
href="#HowdoIdevelopaservice?-JAX-WSProviders">JAX-WS Providers</a></li><li><a
shape="rect" href="#HowdoIdevelopaservice?-Javascript">Javascript</a></li></ul>
</div><h1 id="HowdoIdevelopaservice?-DifferentTypesOfServices">Different Types
Of Services</h1><p>CXF support three major types of services:</p><ul><li>SOAP -
this page summarizes the options for creating SOAP services.</li><li>REST-ful -
REST support is described <a shape="rect"
href="restful-services.html">here</a>.</li><li>CORBA</li></ul><h1
id="HowdoIdevelopaservice?-JAX-WSAnnotatedServicesfromJava">JAX-WS Annotated
Services from Java</h1><p>The JAX-WS APIs include a set of <a shape="rect"
class="external-link"
href="https://jax-ws.java.net/nonav/2.2.8/docs/ch03.html#users-guide-annotations"
rel="nofollow">annotations</a> which allow you to build services using
annotated classes. These services are based on a single class which contains a
set of operations.</p><p>Here's a simple example:</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">@WebService
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">@WebService
public class Hello {
public String sayHi(String name) {
return "Hello " + name;
@@ -132,7 +132,7 @@ public class Hello {
}
</pre>
</div></div><p>JAX-WS includes many more annotations as well such
as:</p><ul><li>@WebMethod - allows you to customize the operation name, exclude
the operation from inclusion in the service, etc</li><li>@WebParam - allows you
to customize a parameter's name, namespace, direction (IN or OUT),
etc</li><li>@WebResult - allows you to customize the return value of the web
service call</li></ul><p>Data is marshalled from XML to Java and vice versa via
the <a shape="rect" href="jaxb.html">JAXB data-binding</a>.</p><p>Services are
publish via one of two means:</p><ul><li>The JAX-WS standard Endpoint
APIs</li><li>CXF's XML configuration format - i.e. <jaxws:endpoint ...
/></li></ul><p>More Information: <a shape="rect"
href="a-simple-jax-ws-service.html">A simple JAX-WS service</a>, <a
shape="rect" href="developing-a-service.html">Developing a JAX-WS Service</a>
(goes into much more depth), <a shape="rect"
href="writing-a-service-with-spring.html">Writing a service with
Spring</a></p><h
1 id="HowdoIdevelopaservice?-JAX-WSAnnotatedServicesfromWSDL">JAX-WS Annotated
Services from WSDL</h1><p>If you have existing WSDLs for your service or wish
to write your WSDL first and then generate classes, CXF has many tools to help
you do this.</p><p>The WSDL2Java tool will generate a JAX-WS annotated service
and server stub from your WSDL. You can run it one of three ways:</p><ul><li><a
shape="rect" href="wsdl-to-java.html">The command line</a></li><li><a
shape="rect" href="using-cxf-with-maven.html">The Maven Plugin</a></li><li>With
the WSDL2Java API</li></ul><p>Note that CXF generally restricts WSDL support to
WSI-BP, not the full WSDL 1.1 specification.</p><p>There is also a <a
shape="rect" href="simple-frontend.html">Simple Frontend</a> that allows you to
create services without usage of Java annotations, using XML configuration
files instead.</p><h1 id="HowdoIdevelopaservice?-JAX-WSProviders">JAX-WS
Providers</h1><p>JAX-WS Providers allow you to create services which work
at the message level - as opposed to the operation level as with annotated
classes. The have a single operation "invoke" which receives either the message
payload (i.e. the SOAP Body) or the whole message itself (i.e. the SOAP
Envelope).</p><p>Here's a simple example:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">@WebServiceProvider
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">@WebServiceProvider
public class HelloProvider {
public Source invoke(Source request) {
return ....;
Modified: websites/production/cxf/content/docs/how-it-works.html
==============================================================================
--- websites/production/cxf/content/docs/how-it-works.html (original)
+++ websites/production/cxf/content/docs/how-it-works.html Wed Sep 13 15:05:52
2017
@@ -32,8 +32,8 @@
<link type="text/css" rel="stylesheet"
href="/resources/highlighter/styles/shThemeCXF.css">
<script src='/resources/highlighter/scripts/shCore.js'></script>
-<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
+<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script>
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
@@ -135,7 +135,7 @@ With xml element attachment in WSDL 1.1,
<p>PolicyAttachments are flexible w.r.t. the type of domain expressions.
Domain expressions are used to identify entities such as endpoints, operations
or messages with which a policy can be associated:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
<wsp:PolicyAttachment>
<wsp:AppliesTo>
<x:DomainExpression/> +
@@ -199,7 +199,7 @@ When the effective message policy is not
Given an assertion type that has attributes, and assuming there are two
instances of assertions of this type, it is possible that the interceptor can
assert one, but not the other. In any case, inability to support all assertions
understood by the interceptor does not necessarily indicate a failure. As
mentioned above in relation to pre-emptive interceptor installation, it is
possible that the ones that cannot be supported do not in fact apply to the
underlying message at all. <br clear="none">
Typically the interceptor would strive at supporting as many of these
assertions as possible however, and to do so it may avail of the
AssertionBuilder's capability to compute a compatible assertion. For example,
by scheduling an acknowledgement to be sent in 3 seconds, an RM interceptor
would support both of the following RMAssertions:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
<wsrmp:RMAssertion
xmlns:wsrmp="http://schemas.xmlsoap.org/ws/2005/02/rm/policy">
<wsrmp:AcknowledgementInterval Milliseconds="30000"/>
</wsrmp:RMAssertion>
Modified: websites/production/cxf/content/docs/how-to-define-policies.html
==============================================================================
--- websites/production/cxf/content/docs/how-to-define-policies.html (original)
+++ websites/production/cxf/content/docs/how-to-define-policies.html Wed Sep 13
15:05:52 2017
@@ -125,7 +125,7 @@ Apache CXF -- How to Define Policies
<h4 id="HowtoDefinePolicies-WSDLPolicyattachment">WSDL Policy attachment</h4>
<p>WS-Policies can be attached and referenced in WSDL elements. <a
shape="rect" class="external-link"
href="http://www.w3.org/TR/ws-policy-attach/" rel="nofollow">Web Services
Policy 1.5 - Attachment </a> standard describes all possible alternatives.
WS-Policies can be placed inside WSDL itself or referenced as external
documents. CXF will automatically recognize, read and use policies defined or
referenced in WSDL. Sample of attached policy is shown below:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
<wsdl:definitions name="HelloWorld"
targetNamespace="http://apache.org/hello_world_soap_http"
…
<wsdl:service name="SOAPService">
@@ -146,7 +146,7 @@ Apache CXF -- How to Define Policies
<p>It is possible to define policies directly in Spring configuration of
client and service as jaxws feature. CXF will recognize and use configured
WS-Policies:<br clear="none">
Client:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:cxf="http://cxf.apache.org/core"
@@ -175,7 +175,7 @@ http://cxf.apache.org/jaxws http://cxf.a
<p>Service:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: bash; gutter: false; theme: Confluence"
style="font-size:12px;">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:cxf="http://cxf.apache.org/core"