From dd78f1de0a2171f61e44477e46f9f54d73d2b464 Mon Sep 17 00:00:00 2001 From: Jonas Partner Date: Tue, 24 Mar 2009 14:27:22 +0000 Subject: [PATCH] docs for http INT-590 --- spring-integration-reference/src/http.xml | 112 ++++++++++++++++++ .../src/spring-integration-reference.xml | 5 +- 2 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 spring-integration-reference/src/http.xml diff --git a/spring-integration-reference/src/http.xml b/spring-integration-reference/src/http.xml new file mode 100644 index 0000000000..42d0b653fb --- /dev/null +++ b/spring-integration-reference/src/http.xml @@ -0,0 +1,112 @@ + + + + Http Support + +
+ Introduction + + The Http support allows for the making of Http requests and the processing of inbound Http requests. Because HTTP is always + request repsonse even if all that is returned is a 200 status code the Http support consists of two gateway implementations + HttpInboundEndpoint and HttpOutboundEndpoint. + +
+ +
+ Http Inbound Gateway + + To receive messages over http you need to use an HttpInboundGateway. 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 web.xml, see + for further details. Below is an example bean defintion for a simple HttpInboundEndpoint + + + +]]> + The HttpInboundGateway accepts an instance of InboundRequestMapper which allows + customisation of the mapping from HttpServletRequest to Message. If none is + provided the an instance of DefaultInboundRequestMapper will be used. This encapsualtes a simple strategy, which for + example will create a String message for a POST request where the content type starts with "text", see the Javadoc for + full details. + + + 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 + implementation of the Spring MVC View which will be invoked with the created Message. + In the case that the gateway should expect a reply to the Message then setting the expectReply flag will cause + the gateway to wait for a reponse Message before creating a 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 + are POST and GET by default. + + + + + + + GET + DELETE + + + + +]]> + + + +
+ +
+ Http Outbound Gateway + + + To configure the HttpOutboundGateway write a bean definition like this: + + +]]> + This bean definition will execute Http requests by first converting the message to the Http request using an instance of + DefaultOutboundRequestMapper. This will expect to find the request URL in the message header under + the key HttpHeaders.REQUEST_URL. It is also possilbe to set a default target URL as a constructor argument + along with other options as shown below. + + + + + +]]> +By default the Http request will be made using an instance of SimpleHttpRequestExecutor which uses the JDK + HttpURLConnection. Use of the Apache Commons Http Client is also supported through the provided + CommonsHttpRequestExecutor which can be injected into the outbound gateway. + +
+ +
+ 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-1.0.xsd'. + + + To configure an inbound http channel adapter which is an instance of HttpInboundEndpoint configured + not to expect a response. + ]]> + + + To configure an inbound http gateway which expects a response. + ]]> + + + 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. + ]]> + +
+
diff --git a/spring-integration-reference/src/spring-integration-reference.xml b/spring-integration-reference/src/spring-integration-reference.xml index 830cea5809..ffbe4ac698 100644 --- a/spring-integration-reference/src/spring-integration-reference.xml +++ b/spring-integration-reference/src/spring-integration-reference.xml @@ -59,7 +59,8 @@ - + + @@ -69,4 +70,4 @@ - \ No newline at end of file +