Author: buildbot
Date: Wed Mar 13 18:57:51 2019
New Revision: 1041790
Log:
Production update by buildbot for cxf
Modified:
websites/production/cxf/content/cache/docs.pageCache
websites/production/cxf/content/docs/jax-rs-client-api.html
Modified: websites/production/cxf/content/cache/docs.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/cxf/content/docs/jax-rs-client-api.html
==============================================================================
--- websites/production/cxf/content/docs/jax-rs-client-api.html (original)
+++ websites/production/cxf/content/docs/jax-rs-client-api.html Wed Mar 13
18:57:51 2019
@@ -117,15 +117,15 @@ Apache CXF -- JAX-RS Client API
<td height="100%">
<!-- Content -->
<div class="wiki-content">
-<div
id="ConfluenceContent"><p> </p><p> </p><p> </p><p> </p><p> <span
style="font-size:2em;font-weight:bold">JAX-RS : Client API</span>
+<div id="ConfluenceContent"><p> <span
style="font-size:2em;font-weight:bold">JAX-RS : Client API</span>
- </p><p><br
clear="none"></p><p> </p><p> </p><p> </p><p> </p><p><style
type="text/css">/*<![CDATA[*/
-div.rbtoc1532300214899 {padding: 0px;}
-div.rbtoc1532300214899 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1532300214899 li {margin-left: 0px;padding-left: 0px;}
+ </p><p><style type="text/css">/*<![CDATA[*/
+div.rbtoc1552503433924 {padding: 0px;}
+div.rbtoc1552503433924 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1552503433924 li {margin-left: 0px;padding-left: 0px;}
-/*]]>*/</style></p><div class="toc-macro rbtoc1532300214899">
+/*]]>*/</style></p><div class="toc-macro rbtoc1552503433924">
<ul class="toc-indentation"><li><a shape="rect"
href="#JAX-RSClientAPI-MavenDependency">Maven Dependency</a></li><li><a
shape="rect" href="#JAX-RSClientAPI-JAX-RS2.0ClientAPI">JAX-RS 2.0 Client
API</a>
<ul class="toc-indentation"><li><a shape="rect"
href="#JAX-RSClientAPI-JAX-RS2.0andCXFspecificAPI">JAX-RS 2.0 and CXF specific
API</a></li></ul>
</li><li><a shape="rect" href="#JAX-RSClientAPI-Proxy-basedAPI">Proxy-based
API</a>
@@ -226,16 +226,16 @@ BusFactory.setDefaultBus(bus);
BookStore proxy = JAXRSClientFactory.create("http://books", BookStore.class);
</pre>
</div></div><h2 id="JAX-RSClientAPI-Injectingproxies">Injecting
proxies</h2><p>For injecting proxies via a spring context, use the jaxrs:client
element like:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"> <jaxrs:client
id="restClient"
-
address="http://localhost:${testutil.ports.BookServerRestSoap}/test/services/rest"
- serviceClass="org.apache.cxf.systest.jaxrs.BookStoreJaxrsJaxws"
- inheritHeaders="true">
- <jaxrs:headers>
- <entry key="Accept" value="text/xml"/>
- </jaxrs:headers>
- </jaxrs:client>
+<pre class="brush: java; gutter: false; theme: Default"><jaxrs:client
id="restClient"
+
address="http://localhost:${testutil.ports.BookServerRestSoap}/test/services/rest"
+ serviceClass="org.apache.cxf.systest.jaxrs.BookStoreJaxrsJaxws"
+ inheritHeaders="true">
+ <jaxrs:headers>
+ <entry key="Accept" value="text/xml"/>
+ </jaxrs:headers>
+</jaxrs:client>
</pre>
-</div></div><p>See this <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml">bean</a>
for a full example of how jaxrs:client can be used to inject a proxy. Note
that WebClient can also be injected as a jaxrs:client.</p><p> </p><h2
id="JAX-RSClientAPI-Asynchronousproxyinvocations">Asynchronous proxy
invocations</h2><p>Starting from CXF 3.1.7 it is possible to do the
asynchronous proxy invocations. One needs to register JAX-RS 2.0 <a
shape="rect" class="external-link"
href="https://jax-rs-spec.java.net/nonav/2.0/apidocs/javax/ws/rs/client/InvocationCallback.html"
rel="nofollow">InvocationCallback</a> as a proxy request context
property:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><p>See this <a shape="rect" class="external-link"
href="https://github.com/apache/cxf/blob/master/systests/jaxrs/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml"
rel="nofollow">bean</a> for a full example of how jaxrs:client can be used to
inject a proxy. Note that WebClient can also be injected as a
jaxrs:client.</p><p> </p><h2
id="JAX-RSClientAPI-Asynchronousproxyinvocations">Asynchronous proxy
invocations</h2><p>Starting from CXF 3.1.7 it is possible to do the
asynchronous proxy invocations. One needs to register JAX-RS 2.0 <a
shape="rect" class="external-link"
href="https://jax-rs-spec.java.net/nonav/2.0/apidocs/javax/ws/rs/client/InvocationCallback.html"
rel="nofollow">InvocationCallback</a> as a proxy request context
property:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">BookStore proxy =
JAXRSClientFactory.create("http://books", BookStore.class);
Book book = null;
@@ -312,7 +312,7 @@ private List<Book> getBooks(WebCli
return books;
}
</pre>
-</div></div><p>The above code will send requests like "GET <a shape="rect"
class="external-link" href="http://books/1" rel="nofollow">http://books/1</a>",
"GET <a shape="rect" class="external-link" href="http://books/2"
rel="nofollow">http://books/2</a>", etc.</p><p>If the request URI can be
parameterized then you may want to use the following code:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>The above code will send requests like "GET <span
class="nolink">http://books/1</span>", "GET <span
class="nolink">http://books/2</span>", etc.</p><p>If the request URI can be
parameterized then you may want to use the following code:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">Book book =
WebClient.create("http://books").path("{year}/{id}", 2010, 123).get(Book.class);
// as opposed to
// WebClient.create("http://books").path(2010).path(123).get(Book.class);
@@ -323,31 +323,28 @@ Collection<? extends Book> books =
</pre>
</div></div><h2 id="JAX-RSClientAPI-Handlingexceptions.1">Handling
exceptions</h2><p>You can handle remote exceptions by either explicitly getting
a Response object as shown above and handling error statuses as needed or you
can catch either javax.ws.rs.WebApplicationException or
javax.ws.rs.ProcessingException exceptions, the same way it can be done with
proxies.</p><h2 id="JAX-RSClientAPI-ConfiguringHTTPclientsinSpring">Configuring
HTTP clients in Spring</h2><p>Like proxies, HTTP clients can be created using a
number of WebClient static utility methods: you can pass a location to a Spring
configuration bean if needed or you can set up a default bus as shown above.
For example:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"><bean
id="myJsonProvider"
-class="org.apache.cxf.jaxrs.provider.JSONProvider" >
- <property name="supportUnwrapped" value="true" />
- <property name="wrapperName" value="nodeName" />
- </bean>
+<pre class="brush: java; gutter: false; theme: Default"><bean
id="myJsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider" >
+ <property name="supportUnwrapped" value="true" />
+ <property name="wrapperName" value="nodeName" />
+</bean>
<util:list id="webClientProviders">
<ref bean="myJsonProvider"/>
</util:list>
-<bean id="myWebClient" class="org.apache.cxf.jaxrs.client.WebClient"
-factory-method="create">
- <constructor-arg type="java.lang.String"
-value="http://some.base.url.that.responds/" />
- <constructor-arg ref="webClientProviders" />
+<bean id="myWebClient" class="org.apache.cxf.jaxrs.client.WebClient"
factory-method="create">
+ <constructor-arg type="java.lang.String"
value="http://some.base.url.that.responds/" />
+ <constructor-arg ref="webClientProviders" />
</bean>
</pre>
</div></div><p>Note, starting from CXF 2.7.5 it is possible to set-up
WebClient instances the same way as proxies, using jaxrs:client:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default"><jaxrs:client
id="webClient"
- address="https://localhost:${port}/services/rest"
- serviceClass="org.apache.cxf.jaxrs.client.WebClient">
- <jaxrs:headers>
- <entry key="Accept" value="text/xml"/>
- </jaxrs:headers>
- </jaxrs:client>
+ address="https://localhost:${port}/services/rest"
+ serviceClass="org.apache.cxf.jaxrs.client.WebClient">
+ <jaxrs:headers>
+ <entry key="Accept" value="text/xml"/>
+ </jaxrs:headers>
+</jaxrs:client>
</pre>
</div></div><p>The only limitation of using this option is that some of
jaxrs:client attributes ("inheritHeaders", "modelRef") and elements ("model")
are not really applicable to WebClient.</p><h1
id="JAX-RSClientAPI-XML-centricclients">XML-centric clients</h1><p>XML-centric
clients are WebClients using an <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/xml/XMLSource.java">XMLSource</a>
utility class. XMLSource has a number of methods facilitating the retrieval of
JAXB beans, individual properties or links with the help of XPath expressions.
For example:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">WebClient wc =
WebClient.create("http://aggregated/data");