Migrate reference guide to well-formed docbook XML
Convert all docbook XML files to well-formed docbook 5 syntax: - Include xsi:schemaLocation element for tools support - Convert all id elements to xml:id - Convert all ulink elements to link - Simplify <lineannotation> mark-up - Fix misplaced </section> tags - Fix <interface> tags to <interfacename> - Cleanup trailing whitespace and tabs Issue: SPR-10032
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<chapter xmlns="http://docbook.org/ns/docbook" version="5.0"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
<chapter xml:id="remoting"
|
||||
xmlns="http://docbook.org/ns/docbook" version="5.0"
|
||||
xmlns:xl="http://www.w3.org/1999/xlink"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
xml:id="remoting">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="
|
||||
http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd
|
||||
http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd">
|
||||
<title>Remoting and web services using Spring</title>
|
||||
|
||||
<section id="remoting-introduction">
|
||||
<section xml:id="remoting-introduction">
|
||||
<title>Introduction</title>
|
||||
|
||||
<para>Spring features integration classes for remoting support using
|
||||
@@ -102,7 +106,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
public void insertAccount(Account acc) {
|
||||
<lineannotation>// do something...</lineannotation>
|
||||
}
|
||||
|
||||
|
||||
public List<Account> getAccounts(String name) {
|
||||
<lineannotation>// do something...</lineannotation>
|
||||
}
|
||||
@@ -113,7 +117,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
show an example using Hessian as the protocol.</para>
|
||||
</section>
|
||||
|
||||
<section id="remoting-rmi">
|
||||
<section xml:id="remoting-rmi">
|
||||
<title>Exposing services using RMI</title>
|
||||
|
||||
<para>Using Spring's support for RMI, you can transparently expose your
|
||||
@@ -125,7 +129,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
example plug in security frameworks or custom security credentials
|
||||
here.</para>
|
||||
|
||||
<section id="remoting-rmi-server">
|
||||
<section xml:id="remoting-rmi-server">
|
||||
<title>Exporting the service using the
|
||||
<classname>RmiServiceExporter</classname></title>
|
||||
|
||||
@@ -151,7 +155,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
<property name="serviceName" value="AccountService"/>
|
||||
<property name="service" ref="accountService"/>
|
||||
<property name="serviceInterface" value="example.AccountService"/>
|
||||
<lineannotation><!-- defaults to <literal>1099</literal> --></lineannotation>
|
||||
<lineannotation><!-- defaults to 1099 --></lineannotation>
|
||||
<property name="registryPort" value="1199"/>
|
||||
</bean></programlisting>
|
||||
|
||||
@@ -169,7 +173,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
</note>
|
||||
</section>
|
||||
|
||||
<section id="remoting-rmi-client">
|
||||
<section xml:id="remoting-rmi-client">
|
||||
<title>Linking in the service at the client</title>
|
||||
|
||||
<para>Our client is a simple object using the
|
||||
@@ -208,14 +212,14 @@ public class AccountServiceImpl implements AccountService {
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="remoting-caucho-protocols">
|
||||
<section xml:id="remoting-caucho-protocols">
|
||||
<title>Using Hessian or Burlap to remotely call services via HTTP</title>
|
||||
|
||||
<para>Hessian offers a binary HTTP-based remoting protocol. It is
|
||||
developed by Caucho and more information about Hessian itself can be found
|
||||
at <ulink url="http://www.caucho.com"></ulink>.</para>
|
||||
at <link xl:href="http://www.caucho.com"></link>.</para>
|
||||
|
||||
<section id="remoting-caucho-protocols-hessian">
|
||||
<section xml:id="remoting-caucho-protocols-hessian">
|
||||
<title>Wiring up the <classname>DispatcherServlet</classname> for
|
||||
Hessian and co.</title>
|
||||
|
||||
@@ -254,7 +258,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
this case.</para>
|
||||
</section>
|
||||
|
||||
<section id="remoting-caucho-protocols-hessian-server">
|
||||
<section xml:id="remoting-caucho-protocols-hessian-server">
|
||||
<title>Exposing your beans by using the
|
||||
<classname>HessianServiceExporter</classname></title>
|
||||
|
||||
@@ -307,7 +311,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
</servlet-mapping></programlisting>
|
||||
</section>
|
||||
|
||||
<section id="remoting-caucho-protocols-hessian-client">
|
||||
<section xml:id="remoting-caucho-protocols-hessian-client">
|
||||
<title>Linking in the service on the client</title>
|
||||
|
||||
<para>Using the <classname>HessianProxyFactoryBean</classname> we can
|
||||
@@ -327,7 +331,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
</bean></programlisting>
|
||||
</section>
|
||||
|
||||
<section id="remoting-caucho-protocols-burlap">
|
||||
<section xml:id="remoting-caucho-protocols-burlap">
|
||||
<title>Using Burlap</title>
|
||||
|
||||
<para>We won't discuss Burlap, the XML-based equivalent of Hessian, in
|
||||
@@ -337,7 +341,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
set to go.</para>
|
||||
</section>
|
||||
|
||||
<section id="remoting-caucho-protocols-security">
|
||||
<section xml:id="remoting-caucho-protocols-security">
|
||||
<title>Applying HTTP basic authentication to a service exposed through
|
||||
Hessian or Burlap</title>
|
||||
|
||||
@@ -354,7 +358,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
<property name="interceptors" ref="authorizationInterceptor"/>
|
||||
</bean>
|
||||
|
||||
<bean id="authorizationInterceptor"
|
||||
<bean id="authorizationInterceptor"
|
||||
class="org.springframework.web.servlet.handler.UserRoleAuthorizationInterceptor">
|
||||
<property name="authorizedRoles" value="administrator,operator"/>
|
||||
</bean></programlisting>
|
||||
@@ -367,13 +371,13 @@ public class AccountServiceImpl implements AccountService {
|
||||
<note>
|
||||
<para>Of course, this example doesn't show a flexible kind of security
|
||||
infrastructure. For more options as far as security is concerned, have
|
||||
a look at the Spring Security project at <ulink
|
||||
url="http://static.springsource.org/spring-security/site/"></ulink>.</para>
|
||||
a look at the Spring Security project at <link
|
||||
xl:href="http://static.springsource.org/spring-security/site/"></link>.</para>
|
||||
</note>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="remoting-httpinvoker">
|
||||
<section xml:id="remoting-httpinvoker">
|
||||
<title>Exposing services using HTTP invokers</title>
|
||||
|
||||
<para>As opposed to Burlap and Hessian, which are both lightweight
|
||||
@@ -387,11 +391,11 @@ public class AccountServiceImpl implements AccountService {
|
||||
<para>Under the hood, Spring uses either the standard facilities provided
|
||||
by J2SE to perform HTTP calls or Commons
|
||||
<classname>HttpClient</classname>. Use the latter if you need more
|
||||
advanced and easy-to-use functionality. Refer to <ulink
|
||||
url="http://jakarta.apache.org/commons/httpclient">jakarta.apache.org/commons/httpclient</ulink>
|
||||
advanced and easy-to-use functionality. Refer to <link
|
||||
xl:href="http://jakarta.apache.org/commons/httpclient">jakarta.apache.org/commons/httpclient</link>
|
||||
for more info.</para>
|
||||
|
||||
<section id="remoting-httpinvoker-server">
|
||||
<section xml:id="remoting-httpinvoker-server">
|
||||
<title>Exposing the service object</title>
|
||||
|
||||
<para>Setting up the HTTP invoker infrastructure for a service object
|
||||
@@ -445,13 +449,13 @@ public class AccountServiceImpl implements AccountService {
|
||||
You can configure the <classname>SimpleHttpServerFactoryBean</classname> together with a
|
||||
<classname>SimpleHttpInvokerServiceExporter</classname> as is shown in this example:</para>
|
||||
|
||||
<programlisting language="xml"><bean name="accountExporter"
|
||||
<programlisting language="xml"><bean name="accountExporter"
|
||||
class="org.springframework.remoting.httpinvoker.SimpleHttpInvokerServiceExporter">
|
||||
<property name="service" ref="accountService"/>
|
||||
<property name="serviceInterface" value="example.AccountService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="httpServer"
|
||||
<bean id="httpServer"
|
||||
class="org.springframework.remoting.support.SimpleHttpServerFactoryBean">
|
||||
<property name="contexts">
|
||||
<util:map>
|
||||
@@ -463,7 +467,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
</programlisting>
|
||||
</section>
|
||||
|
||||
<section id="remoting-httpinvoker-client">
|
||||
<section xml:id="remoting-httpinvoker-client">
|
||||
<title>Linking in the service at the client</title>
|
||||
|
||||
<para>Again, linking in the service from the client much resembles the
|
||||
@@ -490,7 +494,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="remoting-web-services">
|
||||
<section xml:id="remoting-web-services">
|
||||
<title>Web services</title>
|
||||
|
||||
<para>Spring provides full support for standard Java web services
|
||||
@@ -533,13 +537,13 @@ public class AccountServiceImpl implements AccountService {
|
||||
</note>
|
||||
|
||||
<para>In addition to stock support for JAX-RPC and JAX-WS in Spring Core,
|
||||
the Spring portfolio also features <ulink
|
||||
url="http://www.springframework.org/spring-ws">Spring Web
|
||||
Services</ulink>, a solution for contract-first, document-driven web
|
||||
the Spring portfolio also features <link
|
||||
xl:href="http://www.springframework.org/spring-ws">Spring Web
|
||||
Services</link>, a solution for contract-first, document-driven web
|
||||
services - highly recommended for building modern, future-proof web
|
||||
services.</para>
|
||||
|
||||
<section id="remoting-web-services-jaxrpc-export">
|
||||
<section xml:id="remoting-web-services-jaxrpc-export">
|
||||
<title>Exposing servlet-based web services using JAX-RPC</title>
|
||||
|
||||
<para>Spring provides a convenience base class for JAX-RPC servlet
|
||||
@@ -566,7 +570,7 @@ public class AccountServiceImpl implements AccountService {
|
||||
*/</lineannotation>import org.springframework.remoting.jaxrpc.ServletEndpointSupport;
|
||||
|
||||
public class AccountServiceEndpoint extends ServletEndpointSupport implements RemoteAccountService {
|
||||
|
||||
|
||||
private AccountService biz;
|
||||
|
||||
protected void onInit() {
|
||||
@@ -576,7 +580,7 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
||||
public void insertAccount(Account acc) throws RemoteException {
|
||||
biz.insertAccount(acc);
|
||||
}
|
||||
|
||||
|
||||
public Account[] getAccounts(String name) throws RemoteException {
|
||||
return biz.getAccounts(name);
|
||||
}
|
||||
@@ -593,7 +597,7 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
||||
using Axis.</para>
|
||||
</section>
|
||||
|
||||
<section id="remoting-web-services-jaxrpc-access">
|
||||
<section xml:id="remoting-web-services-jaxrpc-access">
|
||||
<title>Accessing web services using JAX-RPC</title>
|
||||
|
||||
<para>Spring provides two factory beans to create JAX-RPC web service
|
||||
@@ -641,11 +645,11 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
||||
<programlisting language="java">public class AccountClientImpl {
|
||||
|
||||
private RemoteAccountService service;
|
||||
|
||||
|
||||
public void setService(RemoteAccountService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
|
||||
public void foo() {
|
||||
try {
|
||||
service.insertAccount(...);
|
||||
@@ -677,11 +681,11 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
||||
<programlisting language="java">public class AccountClientImpl {
|
||||
|
||||
private AccountService service;
|
||||
|
||||
|
||||
public void setService(AccountService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
|
||||
public void foo() {
|
||||
service.insertAccount(...);
|
||||
}
|
||||
@@ -699,7 +703,7 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
||||
on the runtime implications.</para>
|
||||
</section>
|
||||
|
||||
<section id="remoting-web-services-jaxrpc-mapping-registration">
|
||||
<section xml:id="remoting-web-services-jaxrpc-mapping-registration">
|
||||
<title>Registering JAX-RPC Bean Mappings</title>
|
||||
|
||||
<para>To transfer complex objects over the wire such as
|
||||
@@ -733,7 +737,7 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
||||
}</programlisting>
|
||||
</section>
|
||||
|
||||
<section id="remoting-web-services-jaxrpc-handler-registration">
|
||||
<section xml:id="remoting-web-services-jaxrpc-handler-registration">
|
||||
<title>Registering your own JAX-RPC Handler</title>
|
||||
|
||||
<para>In this section we will register our own
|
||||
@@ -793,7 +797,7 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
||||
</bean></programlisting>
|
||||
</section>
|
||||
|
||||
<section id="remoting-web-services-jaxws-export-servlet">
|
||||
<section xml:id="remoting-web-services-jaxws-export-servlet">
|
||||
<title>Exposing servlet-based web services using JAX-WS</title>
|
||||
|
||||
<para>Spring provides a convenient base class for JAX-WS servlet
|
||||
@@ -849,7 +853,7 @@ public class AccountServiceEndpoint extends SpringBeanAutowiringSupport {
|
||||
deployment. See Java EE 5 web service tutorials for details.</para>
|
||||
</section>
|
||||
|
||||
<section id="remoting-web-services-jaxws-export-standalone">
|
||||
<section xml:id="remoting-web-services-jaxws-export-standalone">
|
||||
<title>Exporting standalone web services using JAX-WS</title>
|
||||
|
||||
<para>The built-in JAX-WS provider that comes with Sun's JDK 1.6
|
||||
@@ -903,7 +907,7 @@ public class AccountServiceEndpoint {
|
||||
}</programlisting>
|
||||
</section>
|
||||
|
||||
<section id="remoting-web-services-jaxws-export-ri">
|
||||
<section xml:id="remoting-web-services-jaxws-export-ri">
|
||||
<title>Exporting web services using the JAX-WS RI's Spring
|
||||
support</title>
|
||||
|
||||
@@ -925,12 +929,12 @@ public class AccountServiceEndpoint {
|
||||
beans (through the use of <literal>@Autowired</literal>, as shown
|
||||
above).</para>
|
||||
|
||||
<para>Check out <ulink
|
||||
url="https://jax-ws-commons.dev.java.net/spring/">https://jax-ws-commons.dev.java.net/spring/</ulink>
|
||||
<para>Check out <link
|
||||
xl:href="https://jax-ws-commons.dev.java.net/spring/">https://jax-ws-commons.dev.java.net/spring/</link>
|
||||
for the details on setup and usage style.</para>
|
||||
</section>
|
||||
|
||||
<section id="remoting-web-services-jaxws-access">
|
||||
<section xml:id="remoting-web-services-jaxws-access">
|
||||
<title>Accessing web services using JAX-WS</title>
|
||||
|
||||
<para>Analogous to the JAX-RPC support, Spring provides two factory
|
||||
@@ -995,7 +999,7 @@ public class AccountServiceEndpoint {
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="remoting-jms">
|
||||
<section xml:id="remoting-jms">
|
||||
<title>JMS</title>
|
||||
|
||||
<para>It is also possible to expose services transparently using JMS as
|
||||
@@ -1050,7 +1054,7 @@ public class SimpleCheckingAccountService implements CheckingAccountService {
|
||||
|
||||
</beans></programlisting>
|
||||
|
||||
<section id="remoting-jms-server">
|
||||
<section xml:id="remoting-jms-server">
|
||||
<title>Server-side configuration</title>
|
||||
|
||||
<para>On the server, you just need to expose the service object using
|
||||
@@ -1091,7 +1095,7 @@ public class Server {
|
||||
}</programlisting>
|
||||
</section>
|
||||
|
||||
<section id="remoting-jms-client">
|
||||
<section xml:id="remoting-jms-client">
|
||||
<title>Client-side configuration</title>
|
||||
|
||||
<para>The client merely needs to create a client-side proxy that will
|
||||
@@ -1130,18 +1134,18 @@ public class Client {
|
||||
service.cancelAccount(new Long(10));
|
||||
}
|
||||
}</programlisting>
|
||||
</section>
|
||||
|
||||
<para>You may also wish to investigate the support provided by the <ulink
|
||||
url="http://lingo.codehaus.org/">Lingo</ulink> project, which (to quote
|
||||
<para>You may also wish to investigate the support provided by the <link
|
||||
xl:href="http://lingo.codehaus.org/">Lingo</link> project, which (to quote
|
||||
the homepage blurb) <quote>
|
||||
<emphasis>... is a lightweight POJO based remoting and messaging
|
||||
library based on the Spring Framework's remoting libraries which
|
||||
extends it to support JMS.</emphasis>
|
||||
</quote></para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="remoting-autodection-remote-interfaces">
|
||||
<section xml:id="remoting-autodection-remote-interfaces">
|
||||
<title>Auto-detection is not implemented for remote interfaces</title>
|
||||
|
||||
<para>The main reason why auto-detection of implemented interfaces does
|
||||
@@ -1166,7 +1170,7 @@ public class Client {
|
||||
controlled exposure of specific methods.</para>
|
||||
</section>
|
||||
|
||||
<section id="remoting-considerations">
|
||||
<section xml:id="remoting-considerations">
|
||||
<title>Considerations when choosing a technology</title>
|
||||
|
||||
<para>Each and every technology presented here has its drawbacks. You
|
||||
@@ -1209,7 +1213,7 @@ public class Client {
|
||||
in third-party or custom solutions here.</para>
|
||||
</section>
|
||||
|
||||
<section id="rest-client-access">
|
||||
<section xml:id="rest-client-access">
|
||||
<title>Accessing RESTful services on the Client</title>
|
||||
|
||||
<para>The <classname>RestTemplate</classname> is the core class for
|
||||
@@ -1232,7 +1236,7 @@ public class Client {
|
||||
<classname>RestTemplate</classname> and its associated
|
||||
<interfacename>HttpMessageConverters</interfacename>.</para>
|
||||
|
||||
<section id="rest-resttemplate">
|
||||
<section xml:id="rest-resttemplate">
|
||||
<title>RestTemplate</title>
|
||||
|
||||
<para>Invoking RESTful services in Java is typically done using a helper
|
||||
@@ -1274,63 +1278,63 @@ if (HttpStatus.SC_CREATED == post.getStatusCode()) {
|
||||
<row>
|
||||
<entry>DELETE</entry>
|
||||
|
||||
<entry><ulink
|
||||
url="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#delete(String,%20Object...)">delete</ulink></entry>
|
||||
<entry><link
|
||||
xl:href="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#delete(String,%20Object...)">delete</link></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>GET</entry>
|
||||
|
||||
<entry><ulink
|
||||
url="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#getForObject(String,%20Class,%20Object...)">getForObject</ulink></entry>
|
||||
<entry><link
|
||||
xl:href="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#getForObject(String,%20Class,%20Object...)">getForObject</link></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry></entry>
|
||||
|
||||
<entry><ulink
|
||||
url="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#getForEntity(String,%20Class,%20Object...)">getForEntity</ulink></entry>
|
||||
<entry><link
|
||||
xl:href="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#getForEntity(String,%20Class,%20Object...)">getForEntity</link></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>HEAD</entry>
|
||||
|
||||
<entry><ulink
|
||||
url="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#headForHeaders(String,%20Object...)">headForHeaders(String
|
||||
url, String… urlVariables)</ulink></entry>
|
||||
<entry><link
|
||||
xl:href="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#headForHeaders(String,%20Object...)">headForHeaders(String
|
||||
url, String… urlVariables)</link></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>OPTIONS</entry>
|
||||
|
||||
<entry><ulink
|
||||
url="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#optionsForAllow(String,%20Object...)">optionsForAllow(String
|
||||
url, String… urlVariables)</ulink></entry>
|
||||
<entry><link
|
||||
xl:href="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#optionsForAllow(String,%20Object...)">optionsForAllow(String
|
||||
url, String… urlVariables)</link></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>POST</entry>
|
||||
|
||||
<entry><ulink
|
||||
url="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#postForLocation(String,%20Object,%20Object...)">postForLocation(String
|
||||
url, Object request, String… urlVariables)</ulink></entry>
|
||||
<entry><link
|
||||
xl:href="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#postForLocation(String,%20Object,%20Object...)">postForLocation(String
|
||||
url, Object request, String… urlVariables)</link></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry></entry>
|
||||
|
||||
<entry><ulink
|
||||
url="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#postForObject(java.lang.String,%20java.lang.Object,%20java.lang.Class,%20java.lang.String...)">postForObject(String
|
||||
url, Object request, Class<T> responseType, String…
|
||||
uriVariables)</ulink></entry>
|
||||
<entry><link
|
||||
xl:href="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#postForObject(java.lang.String,%20java.lang.Object,%20java.lang.Class,%20java.lang.String...)">postForObject(String
|
||||
url, Object request, Class<T> responseType, String…
|
||||
uriVariables)</link></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>PUT</entry>
|
||||
|
||||
<entry><ulink
|
||||
url="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#put(String,%20Object,%20Object...)">put(String
|
||||
url, Object request, String…urlVariables)</ulink></entry>
|
||||
<entry><link
|
||||
xl:href="http://static.springsource.org/spring/docs/current/api/org/springframework/web/client/RestTemplate.html#put(String,%20Object,%20Object...)">put(String
|
||||
url, Object request, String…urlVariables)</link></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
@@ -1347,7 +1351,7 @@ if (HttpStatus.SC_CREATED == post.getStatusCode()) {
|
||||
found. In case of an exception processing the HTTP request, an exception
|
||||
of the type <classname>RestClientException</classname> will be
|
||||
thrown; this behavior can be changed by plugging in another <interfacename>ResponseErrorHandler</interfacename>
|
||||
implementation into the <classname>RestTemplate</classname>.</para>
|
||||
implementation into the <classname>RestTemplate</classname>.</para>
|
||||
|
||||
<para>Objects passed to and returned from these methods are converted to
|
||||
and from HTTP messages by
|
||||
@@ -1362,7 +1366,7 @@ if (HttpStatus.SC_CREATED == post.getStatusCode()) {
|
||||
<classname>SourceHttpMessageConverter</classname>. You can override
|
||||
these defaults using the <methodname>messageConverters()</methodname> bean
|
||||
property as would be required if using the
|
||||
<classname>MarshallingHttpMessageConverter</classname> or
|
||||
<classname>MarshallingHttpMessageConverter</classname> or
|
||||
<classname>MappingJackson2HttpMessageConverter</classname>.</para>
|
||||
|
||||
<para>Each method takes URI template arguments in two forms, either as a
|
||||
@@ -1435,57 +1439,57 @@ URI location = template.postForLocation(uri, booking, "1");
|
||||
information on using the execute method and the meaning of its other
|
||||
method arguments.</para>
|
||||
|
||||
<section id="rest-resttemplate-uri">
|
||||
<section xml:id="rest-resttemplate-uri">
|
||||
<title>Working with the URI</title>
|
||||
|
||||
<para>For each of the main HTTP methods, the <classname>RestTemplate</classname>
|
||||
provides variants that either take a String URI or <classname>java.net.URI</classname>
|
||||
as the first argument.
|
||||
</para>
|
||||
|
||||
|
||||
<para>The String URI variants accept template arguments as a
|
||||
String variable length argument or as a <classname>Map<String,String></classname>.
|
||||
They also assume the URL String is not encoded and needs to be encoded.
|
||||
For example the following:
|
||||
They also assume the URL String is not encoded and needs to be encoded.
|
||||
For example the following:
|
||||
</para>
|
||||
|
||||
|
||||
<programlisting language="java">restTemplate.getForObject("http://example.com/hotel list", String.class);</programlisting>
|
||||
|
||||
|
||||
<para>will perform a GET on <filename>http://example.com/hotel%20list</filename>.
|
||||
That means if the input URL String is already encoded, it will be encoded twice --
|
||||
i.e. <filename>http://example.com/hotel%20list</filename> will become
|
||||
<filename>http://example.com/hotel%2520list</filename>.
|
||||
If this is not the intended effect, use the
|
||||
That means if the input URL String is already encoded, it will be encoded twice --
|
||||
i.e. <filename>http://example.com/hotel%20list</filename> will become
|
||||
<filename>http://example.com/hotel%2520list</filename>.
|
||||
If this is not the intended effect, use the
|
||||
<classname>java.net.URI</classname> method variant, which assumes
|
||||
the URL is already encoded is also generally useful if you want
|
||||
to reuse a single (fully expanded) <classname>URI</classname>
|
||||
multiple times.</para>
|
||||
|
||||
<para>The <classname>UriComponentsBuilder</classname> class can be used
|
||||
to build and encode the <classname>URI</classname> including support
|
||||
to build and encode the <classname>URI</classname> including support
|
||||
for URI templates. For example you can start with a URL String:
|
||||
</para>
|
||||
|
||||
<programlisting language="java">UriComponents uriComponents =
|
||||
|
||||
<programlisting language="java">UriComponents uriComponents =
|
||||
UriComponentsBuilder.fromUriString("http://example.com/hotels/{hotel}/bookings/{booking}").build()
|
||||
.expand("42", "21")
|
||||
.encode();
|
||||
|
||||
|
||||
URI uri = uriComponents.toUri();</programlisting>
|
||||
|
||||
<para>Or specify each URI component individually:</para>
|
||||
|
||||
<programlisting language="java">UriComponents uriComponents =
|
||||
|
||||
<programlisting language="java">UriComponents uriComponents =
|
||||
UriComponentsBuilder.newInstance()
|
||||
.scheme("http").host("example.com").path("/hotels/{hotel}/bookings/{booking}").build()
|
||||
.expand("42", "21")
|
||||
.encode();
|
||||
|
||||
URI uri = uriComponents.toUri();</programlisting>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
<section id="rest-template-headers">
|
||||
<section xml:id="rest-template-headers">
|
||||
<title>Dealing with request and response headers</title>
|
||||
|
||||
<para>Besides the methods described above, the <classname>RestTemplate</classname>
|
||||
@@ -1493,7 +1497,7 @@ URI uri = uriComponents.toUri();</programlisting>
|
||||
used for arbitrary HTTP method execution based on the <classname>HttpEntity</classname>
|
||||
class.</para>
|
||||
|
||||
<para>Perhaps most importantly, the <methodname>exchange()</methodname>
|
||||
<para>Perhaps most importantly, the <methodname>exchange()</methodname>
|
||||
method can be used to add request headers and read response headers.
|
||||
For example:</para>
|
||||
|
||||
@@ -1513,7 +1517,7 @@ String body = response.getBody();</programlisting>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="rest-message-conversion">
|
||||
<section xml:id="rest-message-conversion">
|
||||
<title>HTTP Message Conversion</title>
|
||||
|
||||
<para>Objects passed to and returned from the methods
|
||||
@@ -1557,7 +1561,7 @@ String body = response.getBody();</programlisting>
|
||||
can be overridden by setting the
|
||||
<classname>supportedMediaTypes</classname> bean property</para>
|
||||
|
||||
<section id="rest-string-converter">
|
||||
<section xml:id="rest-string-converter">
|
||||
<title>StringHttpMessageConverter</title>
|
||||
|
||||
<para>An <interfacename>HttpMessageConverter</interfacename>
|
||||
@@ -1568,7 +1572,7 @@ String body = response.getBody();</programlisting>
|
||||
<literal>text/plain</literal>.</para>
|
||||
</section>
|
||||
|
||||
<section id="rest-form-converter">
|
||||
<section xml:id="rest-form-converter">
|
||||
<title>FormHttpMessageConverter</title>
|
||||
|
||||
<para>An <interfacename>HttpMessageConverter</interfacename>
|
||||
@@ -1579,7 +1583,7 @@ String body = response.getBody();</programlisting>
|
||||
String></literal>.</para>
|
||||
</section>
|
||||
|
||||
<section id="rest-byte-converter">
|
||||
<section xml:id="rest-byte-converter">
|
||||
<title>ByteArrayHttpMessageConverter</title>
|
||||
|
||||
<para>An <interfacename>HttpMessageConverter</interfacename>
|
||||
@@ -1592,7 +1596,7 @@ String body = response.getBody();</programlisting>
|
||||
overriding <literal>getContentType(byte[])</literal>.</para>
|
||||
</section>
|
||||
|
||||
<section id="rest-marhsalling-converter">
|
||||
<section xml:id="rest-marhsalling-converter">
|
||||
<title>MarshallingHttpMessageConverter</title>
|
||||
|
||||
<para>An <interfacename>HttpMessageConverter</interfacename>
|
||||
@@ -1606,22 +1610,22 @@ String body = response.getBody();</programlisting>
|
||||
this converter supports (<literal>text/xml</literal>) and
|
||||
(<literal>application/xml</literal>).</para>
|
||||
</section>
|
||||
|
||||
<section id="rest-mapping-json-converter">
|
||||
|
||||
<section xml:id="rest-mapping-json-converter">
|
||||
<title>MappingJackson2HttpMessageConverter (or MappingJacksonHttpMessageConverter with Jackson 1.x)</title>
|
||||
|
||||
<para>An <interfacename>HttpMessageConverter</interfacename>
|
||||
implementation that can read and write JSON using Jackson's
|
||||
<interfacename>ObjectMapper</interfacename>. JSON mapping can be
|
||||
customized as needed through the use of Jackson's provided annotations. When
|
||||
further control is needed, a custom
|
||||
<interfacename>ObjectMapper</interfacename> can be injected through
|
||||
the <literal>ObjectMapper</literal> property for cases where custom
|
||||
JSON serializers/deserializers need to be provided for specific types.
|
||||
|
||||
<para>An <interfacename>HttpMessageConverter</interfacename>
|
||||
implementation that can read and write JSON using Jackson's
|
||||
<interfacename>ObjectMapper</interfacename>. JSON mapping can be
|
||||
customized as needed through the use of Jackson's provided annotations. When
|
||||
further control is needed, a custom
|
||||
<interfacename>ObjectMapper</interfacename> can be injected through
|
||||
the <literal>ObjectMapper</literal> property for cases where custom
|
||||
JSON serializers/deserializers need to be provided for specific types.
|
||||
By default this converter supports (<literal>application/json</literal>).</para>
|
||||
</section>
|
||||
|
||||
<section id="rest-source-converter">
|
||||
<section xml:id="rest-source-converter">
|
||||
<title>SourceHttpMessageConverter</title>
|
||||
|
||||
<para>An <interfacename>HttpMessageConverter</interfacename>
|
||||
@@ -1634,7 +1638,7 @@ String body = response.getBody();</programlisting>
|
||||
(<literal>application/xml</literal>).</para>
|
||||
</section>
|
||||
|
||||
<section id="rest-buffered-image-converter">
|
||||
<section xml:id="rest-buffered-image-converter">
|
||||
<title>BufferedImageHttpMessageConverter</title>
|
||||
|
||||
<para>An <interfacename>HttpMessageConverter</interfacename>
|
||||
|
||||
Reference in New Issue
Block a user