updated http docs for the new RestTemplate based outbound gateway
This commit is contained in:
@@ -6,15 +6,15 @@
|
||||
<section id="http-intro">
|
||||
<title>Introduction</title>
|
||||
<para>
|
||||
The HTTP support allows for the making of HTTP requests and the processing of inbound Http requests. Because interaction over HTTP is always synchronous, even if all that is returned is a 200 status code the Http support consists of two gateway implementations
|
||||
<classname>HttpInboundEndpoint</classname> and <classname>HttpOutboundEndpoint</classname>.
|
||||
The HTTP support allows for the execution of HTTP requests and the processing of inbound HTTP requests. Because interaction over HTTP is always synchronous, even if all that is returned is a 200 status code, the HTTP support consists of two gateway implementations:
|
||||
<classname>HttpInboundEndpoint</classname> and <classname>HttpRequestExecutingMessageHandler</classname>.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="http-inbound">
|
||||
<title>Http Inbound Gateway</title>
|
||||
<para>
|
||||
To receive messages over http you need to use an <classname>HttpInboundEndpoint</classname>. In common with the HttpInvoker
|
||||
To receive messages over HTTP you need to use an <classname>HttpInboundEndpoint</classname>. In common with the HttpInvoker
|
||||
support the Http Inbound Gateway needs to be deployed within a servlet container. The easiest way to do this is to provide a servlet
|
||||
definition in <emphasis>web.xml</emphasis>, see
|
||||
<xref linkend="httpinvoker-inbound"/> for further details. Below is an example bean definition for a simple <classname>HttpInboundEndpoint</classname>
|
||||
@@ -42,12 +42,12 @@
|
||||
</note>
|
||||
</para>
|
||||
<para>
|
||||
In sending a response to the client there are a number of ways to customise the behaviour of the gateway. By default the gateway will
|
||||
simply acknowledge that the request was received by sending a 200 status code back. It is possible to customise this response by providing an
|
||||
In sending a response to the client there are a number of ways to customize the behavior of the gateway. By default the gateway will
|
||||
simply acknowledge that the request was received by sending a 200 status code back. It is possible to customize this response by providing an
|
||||
implementation of the Spring MVC <interfacename>View</interfacename> which will be invoked with the created <interfacename>Message</interfacename>.
|
||||
In the case that the gateway should expect a reply to the <interfacename>Message</interfacename> then setting the <property>expectReply</property> flag will cause
|
||||
the gateway to wait for a response <interfacename>Message</interfacename> before creating an Http response. Below is an example of a gateway
|
||||
configured to use a custom view and to wait for a response. It also shows how to customise the Http methods accepted by the gateway, which
|
||||
configured to use a custom view and to wait for a response. It also shows how to customize the Http methods accepted by the gateway, which
|
||||
are <emphasis>POST</emphasis> and <emphasis>GET</emphasis> by default.
|
||||
<programlisting language="xml"><![CDATA[<bean id="httpInbound" class="org.springframework.integration.http.HttpInboundEndpoint">
|
||||
<property name="requestChannel" ref="httpRequestChannel" />
|
||||
@@ -72,33 +72,33 @@
|
||||
<title>Http Outbound Gateway</title>
|
||||
|
||||
<para>
|
||||
To configure the <classname>HttpOutboundEndpoint</classname> write a bean definition like this:
|
||||
<programlisting language="xml"><![CDATA[<bean id="httpOutbound" class="org.springframework.integration.http.HttpOutboundEndpoint" >
|
||||
To configure the <classname>HttpRequestExecutingMessageHandler</classname> write a bean definition like this:
|
||||
<programlisting language="xml"><![CDATA[<bean id="httpOutbound" class="org.springframework.integration.http.HttpRequestExecutingMessageHandler" >
|
||||
<property name="outputChannel" ref="responseChannel" />
|
||||
</bean>]]></programlisting>
|
||||
This bean definition will execute Http requests by first converting the message to the Http request using an instance of
|
||||
<classname>DefaultOutboundRequestMapper</classname>. This will expect to find the request URL in the message header under
|
||||
the key <emphasis>HttpHeaders.REQUEST_URL</emphasis>. It is also possible to set a default target URL as a constructor argument
|
||||
This bean definition will execute HTTP requests by first converting the message to an HTTP request using an instance of
|
||||
<classname>DefaultOutboundRequestMapper</classname>. It will also expect to find the request URL in the message header under
|
||||
the key <emphasis>HttpHeaders.REQUEST_URL</emphasis>. However, it is also possible to set a default URL as a constructor argument
|
||||
along with other options as shown below.
|
||||
<programlisting language="xml"><![CDATA[<bean id="httpOutbound" class="org.springframework.integration.http.HttpOutboundEndpoint" >
|
||||
<programlisting language="xml"><![CDATA[<bean id="httpOutbound" class="org.springframework.integration.http.HttpRequestExecutingMessageHandler" >
|
||||
<constructor-arg value="http://localhost:8080/example" />
|
||||
<property name="outputChannel" ref="responseChannel" />
|
||||
<property name="sendTimeout" value="5000" />
|
||||
<property name="requestMapper" ref="customRequestMapper" />
|
||||
</bean>]]></programlisting>
|
||||
By default the Http request will be made using an instance of <classname>SimpleHttpRequestExecutor</classname> which uses the JDK
|
||||
<classname>HttpURLConnection</classname>. Use of the Apache Commons Http Client is also supported through the provided
|
||||
<classname>CommonsHttpRequestExecutor</classname> which can be injected into the outbound gateway.
|
||||
By default the HTTP request will be generated using an instance of <classname>SimpleClientHttpRequestFactory</classname> which uses the JDK
|
||||
<classname>HttpURLConnection</classname>. Use of the Apache Commons HTTP Client is also supported through the provided
|
||||
<classname>CommonsClientHttpRequestFactory</classname> which can be injected into the outbound gateway.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="http-namespace">
|
||||
<title>Http Namespace Support</title>
|
||||
<title>HTTP Namespace Support</title>
|
||||
<para>
|
||||
Spring Integration provides an "http" namespace and schema definition. To include it in your
|
||||
configuration, simply provide the following URI within a namespace declaration:
|
||||
'http://www.springframework.org/schema/integration/http'. The schema location should then map to
|
||||
'http://www.springframework.org/schema/integration/http/spring-integration-http-1.0.xsd'.
|
||||
'http://www.springframework.org/schema/integration/http/spring-integration-http.xsd'.
|
||||
</para>
|
||||
<para>
|
||||
To configure an inbound http channel adapter which is an instance of <classname>HttpInboundEndpoint</classname> configured
|
||||
@@ -116,12 +116,12 @@ By default the Http request will be made using an instance of <classname>SimpleH
|
||||
default-url="http://localhost/test"
|
||||
extract-request-payload="false"
|
||||
charset="UTF-8"
|
||||
request-executor="executor"
|
||||
request-factory="requestFactory"
|
||||
request-timeout="1234"
|
||||
reply-channel="replies"/>]]></programlisting>
|
||||
If you want to provide a custom OutboundRequestMapper, then a reference may be supplied to the
|
||||
'request-mapper' attribute. In that case however you will not be allowed to set the default URL,
|
||||
charset, and 'extract-request-payload' properties since those are all properties of the default
|
||||
'request-mapper' attribute. In that case however you will not be allowed to set the 'charset'
|
||||
or 'extract-request-payload' attributes since those are both properties of the default
|
||||
mapper (see the JavaDoc for DefaultOutboundRequestMapper for more information).
|
||||
</para>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user