diff --git a/spring-integration-http/src/main/resources/org/springframework/integration/http/config/spring-integration-http-2.1.xsd b/spring-integration-http/src/main/resources/org/springframework/integration/http/config/spring-integration-http-2.1.xsd
index a385c2b797..535cbc16d4 100644
--- a/spring-integration-http/src/main/resources/org/springframework/integration/http/config/spring-integration-http-2.1.xsd
+++ b/spring-integration-http/src/main/resources/org/springframework/integration/http/config/spring-integration-http-2.1.xsd
@@ -27,8 +27,19 @@
- [DEPRECATED since v2.1] Use 'path' attribute if you want to specify the path or
- 'id' attribute if you simply want to identify this component
+ [DEPRECATED since v2.1] Use the 'path' attribute if you want
+ to specify the path or the 'id' attribute if you simply want
+ to identify this component.
+
+ When using the 'path' attribute, please ensure to also
+ declare a handler mapping bean of type
+ 'org.springframework.integration.http.inbound.UriPathHandlerMapping'.
+
+ This bean is used by the Spring MVC DispatcherServlet
+ to evaluate which URL maps to which inbound endpoint.
+ For more information please see the chapter on
+ 'Handler mappings' in the Spring Framework Reference
+ Documentation.
@@ -63,7 +74,7 @@
In the case that a view-name is specified this attribute can be used to
override the default key of the Errors (if the request cannot be handled).
Defaults to "errors" (similar to normal MVC
- usage).
+ usage).
@@ -77,7 +88,16 @@
- Allows you to specify URI path (e.g., /orderId/{order})
+ Allows you to specify the URI path (e.g., /orderId/{order})
+
+ When using the 'path' attribute, please ensure to also
+ declare a handler mapping bean of type
+ 'org.springframework.integration.http.inbound.UriPathHandlerMapping'.
+
+ This bean is used by the Spring MVC DispatcherServlet to
+ evaluate which URL maps to which inbound endpoint. For
+ more information please see the chapter on 'Handler mappings'
+ in the Spring Framework Reference Documentation.
@@ -118,7 +138,7 @@ this list can also be simple patterns to be matched against the header names (e.
The String "HTTP_REQUEST_HEADERS" will match against any of the standard HTTP Request headers.
]]>
-
+
@@ -127,7 +147,7 @@ The String "HTTP_REQUEST_HEADERS" will match against any of the standard HTTP Re
-
+
@@ -143,7 +163,25 @@ The String "HTTP_REQUEST_HEADERS" will match against any of the standard HTTP Re
-
+
+
+
+ [DEPRECATED since v2.1] Use the 'path' attribute if you want
+ to specify the path or the 'id' attribute if you simply want
+ to identify this component.
+
+ When using the 'path' attribute, please ensure to also
+ declare a handler mapping bean of type
+ 'org.springframework.integration.http.inbound.UriPathHandlerMapping'.
+
+ This bean is used by the Spring MVC DispatcherServlet
+ to evaluate which URL maps to which inbound endpoint.
+ For more information please see the chapter on
+ 'Handler mappings' in the Spring Framework Reference
+ Documentation.
+
+
+
@@ -158,7 +196,7 @@ The String "HTTP_REQUEST_HEADERS" will match against any of the standard HTTP Re
In the case that a view-name is specified this attribute can be used to
override the default key of the Errors (if the request cannot be handled).
- Defaults to "errors" (similar to normal MVC usage).
+ Defaults to "errors" (similar to normal MVC usage).
@@ -172,7 +210,17 @@ The String "HTTP_REQUEST_HEADERS" will match against any of the standard HTTP Re
- Allows you to specify URI path (e.g., /orderId/{order})
+ Allows you to specify the URI path (e.g., /orderId/{order})
+
+ When using the 'path' attribute, please ensure to also
+ declare a handler mapping bean of type
+ 'org.springframework.integration.http.inbound.UriPathHandlerMapping'.
+
+ This bean is used by the Spring MVC DispatcherServlet
+ to evaluate which URL maps to which inbound endpoint.
+ For more information please see the chapter on
+ 'Handler mappings' in the Spring Framework Reference
+ Documentation.
@@ -191,7 +239,7 @@ The String "HTTP_REQUEST_HEADERS" will match against any of the standard HTTP Re
In the case that a view-name is not specified this attribute can be used to
override the default behaviour when there is a message handling exception (which
- is to rethrow). If this flag is true then the normal conversion process will be
+ is to rethrow). If this flag is true then the normal conversion process will be
applied to the exception and written out to the response body.
@@ -240,7 +288,7 @@ The String "HTTP_REQUEST_HEADERS" will match against any of the standard HTTP Re
-
- The HTTP method to use when executing requests with this adapter.
+ The HTTP method to use when executing requests with this adapter.
@@ -307,7 +355,7 @@ The String "HTTP_REQUEST_HEADERS" will match against any of the standard HTTP Re
- The expected type to which the response body should be converted.
+ The expected type to which the response body should be converted.
@@ -406,7 +454,7 @@ The String "HTTP_REQUEST_HEADERS" will match against any of the standard HTTP Re
- The HTTP method to use when executing requests with this adapter.
+ The HTTP method to use when executing requests with this adapter.
@@ -463,7 +511,7 @@ The String "HTTP_REQUEST_HEADERS" will match against any of the standard HTTP Re
- The expected type to which the response body should be converted.
+ The expected type to which the response body should be converted.
@@ -543,7 +591,7 @@ The String "HTTP_REQUEST_HEADERS" will match against any of the standard HTTP Re
-
+
web.xml, see
for further details. Below is an example bean definition for a simple HTTP inbound endpoint.
-
@@ -52,7 +52,7 @@
configured to serve as a Spring MVC Controller with a view name. Because of the constructor arg value of TRUE, it wait for a reply. This also shows
how to customize the HTTP methods accepted by the gateway, which
are POST and GET by default.
-
@@ -76,7 +76,7 @@
To configure the HttpRequestExecutingMessageHandler write a bean definition like this:
-
@@ -84,7 +84,7 @@
This bean definition will execute HTTP requests by delegating to a RestTemplate. That template in turn delegates
to a list of HttpMessageConverters to generate the HTTP request body from the Message payload. You can configure those converters as well
as the ClientHttpRequestFactory instance to use:
-
@@ -104,7 +104,7 @@ In the case of the Outbound Gateway, the reply message produced by the gateway w
Basic cookie support is provided by the transfer-cookies attribute on the outbound gateway. When
set to true (default is false), a Set-Cookie header received from the server in a response will be
- converted to Cookie in the reply message. This header will then be used
+ converted to Cookie in the reply message. This header will then be used
on subsequent sends. This enables simple stateful interactions, such as...
@@ -117,30 +117,139 @@ In the case of the Outbound Gateway, the reply message produced by the gateway w
+
HTTP Namespace Support
-
- 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.xsd'.
-
+
- To configure an inbound http channel adapter which is an instance of HttpInboundEndpoint configured
- not to expect a response.
- http namespace and
+ the corresponding schema definition. To include it in your configuration,
+ simply provide the following namespace declaration in your application
+ context configuration file:
+
+
+
+
+ ...
+]]>
+
+ Inbound
+
+
+ The XML Namespace provides two components for handling HTTP Inbound
+ requests. In order to process requests without returning a dedicated
+ response, use the inbound-channel-adapter:
+
+
+ ]]>
-
+
- To configure an inbound http gateway which expects a response.
- ]]>
+ To process requests that do expect a response, use an
+ inbound-gateway:
+
+ ]]>
+
+
+
+ Beginning with Spring Integration 2.1 the
+ HTTP Inbound Gateway and the HTTP
+ Inbound Channel Adapter should use the path
+ attribute instead of the name attribute for
+ specifying the request path. The name attribute
+ for those 2 components has been deprecated.
+
+
+ If you simply want to identify component itself within your application
+ context, please use the id attribute.
+
+
+
+ Defining the UriPathHandlerMapping
+
+
+ In order to use the HTTP Inbound Gateway or the
+ HTTP Inbound Channel Adapter you must define a
+
+ UriPathHandlerMapping. This particular implementation of the
+ HandlerMapping matches against
+ the value of the path attribute.
+
+
+ ]]>
+
+ For more information regarding Handler Mappings, please
+ see:
+
+
+
+
+
+
+
+
+ URI Template Variables and Expressions
+
+
+ By Using the path attribute in conjunction with the
+ payload-expression attribute as well as the
+ header sub-element, you have a high degree of flexiblity for
+ mapping inbound request data.
+
+
+
+ In the following example configuration, an Inbound Channel Adapter is
+ configured to accept requests using the following URI:
+ /first-name/{firstName}/last-name/{lastName}
+
+
+
+ Using the payload-expression attribute, the URI
+ template variable {firstName} is mapped to be the
+ Message payload, while the {lastName} URI template
+ variable will map to the lname Message header.
+
+
+
+
+]]>
+
+
+ For more information about URI template variables,
+ please see the Spring Reference Manual:
+
+
+
+
+
+
+
+
+ Outbound
+
To configure the outbound gateway you can use the namespace support as well. The following code snippet shows the different configuration options for an outbound Http gateway. Most importantly, notice that the 'http-method' and 'expected-response-type' are provided. Those are two of the most commonly configured values. The
default http-method is POST, and the default response type is null. With a null response type, the payload of the reply Message would only
contain the status code (e.g. 200) as long as it's a successful status (non-successful status codes will throw Exceptions). If you are expecting a different
type, such as a String, then provide that fully-qualified class name as shown below.
+
]]>
-
+
+ Beginning with Spring Integration 2.1 the request-timeout attribute
+ of the HTTP Outbound Gateway was renamed to reply-timeout
+ to better reflect the intent.
+
If your outbound adapter is to be used in a unidirectional way, then you can use an outbound-channel-adapter instead. This means that
a successful response will simply execute without sending any Messages to a reply channel. In the case of any non-successful response
status code, it will throw an exception. The configuration looks very similar to the gateway:
@@ -167,43 +280,224 @@ In the case of the Outbound Gateway, the reply message produced by the gateway w
auto-startup="false"/>]]>
- Mapping URI variables
+ Mapping URI variables
- If your URL contains URI variables you can map them using uri-variable sub element in
- Http Outbound Gateway configuration.
-
+ If your URL contains URI variables, you can map them using the
+ uri-variable sub-element. This sub-element is available for the Http Outbound Gateway
+ and the Http Outbound Channel Adapter.
+
+
]]>
-
- The uri-variable defines two attributes expression and value. You generally use
- the value attribute for literal values, but if the value you are trying to inject is dynamic and requires
- access to Message data you can use a SpEL expression via the expression attribute. In the above configuration
- the getZip() method will be invoked on the payload object of the Message and the result of that
- method will be used as the value for URI variable named 'zipCode'.
+
+ The uri-variable sub-element defines two attributes:
+ name and expression. The name attribute
+ identifies the name of the URI variable, while the expression
+ attribute is used to set the actual value. Using the expression
+ attribute, you can leverage the full power of the Spring Expression Language
+ (SpEL) which gives you full dynamic access to the message payload and the
+ message headers. For example, in the above configuration the getZip()
+ method will be invoked on the payload object of the Message and the result
+ of that method will be used as the value for the URI variable named 'zipCode'.
-
+
+
+ Timeout Handling
+
+
+ In the context of HTTP components, there are two timing areas that have to be
+ considered.
+
+
+
+ Timeouts when interacting with Spring Integration Channels
+ Timeouts when interacting with a remote HTTP server
+
+
+
+ First, the components interact with Message Channels, for
+ which timeouts can be specified. For example, an HTTP Inbound
+ Gateway will forward messages received from connected HTTP Clients to a
+ Message Channel (Request Timeout) and consequently the HTTP Inbound Gateway
+ will receive a reply Message from the Reply Channel (Reply Timeout) that
+ will be used to generate the HTTP Response. Please see the figure below
+ for an illustration.
+
+
+
+
+
+
+
+
+
+
+ How timeout settings apply to an HTTP Inbound Gateway
+
+
+
+
+ For outbound endpoints, the second thing to consider is timing while
+ interacting with the remote server.
+
+
+
+
+
+
+
+
+
+
+ How timeout settings apply to an HTTP Outbound Gateway
+
+
+
+
+ You may want to configure the HTTP related timeout behavior, when
+ making active HTTP requests using the HTTP Oubound Gateway
+ or the HTTP Outbound Channel Adapter. In those
+ instances, these two components use Spring's
+ RestTemplate
+ support to execute HTTP requests.
+
+
+ In order to configure timeouts for the
+ HTTP Oubound Gateway and the
+ HTTP Outbound Channel Adapter, you can either
+ reference a RestTemplate bean directly, using the
+ rest-template attribute, or you can provide a reference to a
+ ClientHttpRequestFactory
+ bean using the request-factory attribute. Spring provides
+ the following implementations of the
+ ClientHttpRequestFactory interface:
+
+
+
+ SimpleClientHttpRequestFactory
+ - Uses standard J2SE facilities for making HTTP Requests
+
+
+ HttpComponentsClientHttpRequestFactory
+ - Uses Apache HttpComponents HttpClient (Since Spring 3.1)
+
+
+ ClientHttpRequestFactory
+ - Uses Jakarta Commons HttpClient (Deprecated as of Spring 3.1)
+
+
+
+ If you don't explicitly configure the request-factory
+ or rest-template attribute respectively, then a default
+ RestTemplate which uses a SimpleClientHttpRequestFactory
+ will be instantiated.
+
+
+
+
+ With some JVM implementations, the handling of timeouts using
+ the URLConnection class may not be consistent.
+
+
+ E.g. from the Java™ Platform, Standard Edition 6 API Specification
+ on setConnectTimeout: Some non-standard
+ implmentation of this method may ignore the specified timeout. To see
+ the connect timeout set, please call getConnectTimeout().
+
+
+ Please test your timeouts if you have specific needs. Consider using the
+ HttpComponentsClientHttpRequestFactory which, in turn, uses
+ Apache HttpComponents HttpClient
+ instead.
+
+
+
+
+ Here is an example of how to configure an HTTP Outbound Gateway
+ using a SimpleClientHttpRequestFactory, configured
+ with connect and read timeouts of 5 seconds respectively:
+
+
+
+
+
+
+
+
+
+]]>
+
+ HTTP Outbound Gateway
+
+ For the HTTP Outbound Gateway, the XML Schema defines
+ only the reply-timeout. The reply-timeout
+ maps to the sendTimeout property of the
+ org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler
+ class. More precisely, the property is set on the extended
+ AbstractReplyProducingMessageHandler class, which
+ ultimatelly sets the property on the MessagingTemplate.
+
+
+ The value of the sendTimeout property defaults to "-1"
+ and will be applied to the connected MessageChannel.
+ This means, that depending on the implementation, the Message Channel's
+ send method may block indefinitely. Furthermore,
+ the sendTimeout property is only used, when the
+ actual MessageChannel implementation has a blocking send (such as 'full' bounded QueueChannel).
+
+
+ HTTP Inbound Gateway
+
+ For the HTTP Inbound Gateway, the XML Schema defines
+ the request-timeout attribute, which will be used
+ to set the requestTimeout property on the
+ HttpRequestHandlingMessagingGateway class
+ (on the extended MessagingGatewaySupport class). Secondly, the
+ reply-timeout attribute exists and it maps to the
+ replyTimeout property on the same class.
+
+
+ The default for both timeout properties is "1000ms". Ultimately, the
+ request-timeout property will be used to set the
+ sendTimeout on the used MessagingTemplate
+ instance. The replyTimeout property on the other
+ hand, will be used to set the receiveTimeout
+ property on the used MessagingTemplate instance.
+
+
+ In order to simulate connection timeouts, connect to a non-routable IP
+ address, for example 10.255.255.10.
+
+
+
HTTP Proxy configuration
-
+
If you are behind a proxy and need to configure proxy settings for HTTP outbound adapters and/or
gateways, you can apply one of two approaches. In most cases, you can rely on the standard Java
System Properties that control the proxy settings. Otherwise, you can explicitly configure a
Spring bean for the HTTP client request factory instance.
-
+
Standard Java Proxy configuration
-
+
There are 3 System Properties you can set to configure the proxy settings that will be used by the HTTP protocol handler:
@@ -214,15 +508,15 @@ In the case of the Outbound Gateway, the reply message produced by the gateway w
http.proxyPort - the port number, the default value being 80.
-
+
- http.nonProxyHosts - a list of hosts that should be reached directly,
+ http.nonProxyHosts - a list of hosts that should be reached directly,
bypassing the proxy. This is a list of patterns separated by '|'. The patterns may start or end with a '*' for wildcards. Any host matching one of these patterns will be reached through a direct connection instead of through a proxy.
-
+
And for HTTPS:
-
+
https.proxyHost - the host name of the proxy server.
@@ -230,18 +524,18 @@ In the case of the Outbound Gateway, the reply message produced by the gateway w
https.proxyPort - the port number, the default value being 80.
-
+
For more information please refer to this document: http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html
-
+
Spring's SimpleClientHttpRequestFactory
If for any reason, you need more explicit control over the proxy configuration, you can use Spring's
SimpleClientHttpRequestFactory and configure its 'proxy' property as such:
-
@@ -255,47 +549,47 @@ In the case of the Outbound Gateway, the reply message produced by the gateway w
-
+
]]>
-
+
-
+
HTTP Samples
diff --git a/src/reference/docbook/images/http-inbound-gateway-pdf.png b/src/reference/docbook/images/http-inbound-gateway-pdf.png
new file mode 100644
index 0000000000..5d9c8090c7
Binary files /dev/null and b/src/reference/docbook/images/http-inbound-gateway-pdf.png differ
diff --git a/src/reference/docbook/images/http-inbound-gateway.png b/src/reference/docbook/images/http-inbound-gateway.png
new file mode 100644
index 0000000000..97ab42dd06
Binary files /dev/null and b/src/reference/docbook/images/http-inbound-gateway.png differ
diff --git a/src/reference/docbook/images/http-outbound-gateway-pdf.png b/src/reference/docbook/images/http-outbound-gateway-pdf.png
new file mode 100644
index 0000000000..be04ff0788
Binary files /dev/null and b/src/reference/docbook/images/http-outbound-gateway-pdf.png differ
diff --git a/src/reference/docbook/images/http-outbound-gateway.png b/src/reference/docbook/images/http-outbound-gateway.png
new file mode 100644
index 0000000000..f71b4ece76
Binary files /dev/null and b/src/reference/docbook/images/http-outbound-gateway.png differ