Announcement Announcement Module
No announcement yet.
support for URL Expression for Http Outbound adapter/gateway for Post call Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • support for URL Expression for Http Outbound adapter/gateway for Post call explains the scenario in case of Get call.

    thats is

    <int-http:outbound-gateway url="{url}" request-channel="vmwChannel" reply-channel="replyChannel"
    expected-response-type="java.lang.String" http-method="GET">
    <int-http:uri-variable name="url" expression="payload" encode="false"/>

    How do we handle when we have a Post call with a request body and a dynamic url
    If i try putting both(string url , object ) in the payload it gives me an error - Cannot add 2 objects in payload.

    I also read some where I can add the dynamic url into the header. But how to add values in header when I am using Spring integration and NOT USING Rest Template object

    Please suggest how do I handle Post calls

  • #2
    You can put the URL (or better yet just the part(s) you need to be dynamic) into one or more Message headers. Then for the expression use "headers.someName" instead of "payload". The payload itself should be what you want converted into the request body. Of course, you also need to change the "http-method" attribute's value to "POST".


    • #3
      Hi Mark
      I am unable to add Headers

      I tried 2 approaches---->


      I defined a header-mapper
      In the file ShoppingListHeaderMapper I extended DefaultHttpHeaderMapper and added the headers
      given below code for your reference

      <!-- Defining HTTP outbound Gateway Interface -->
      <bean id="jsonHeaderMapper" class=" stHeaderMapper"/>

      <int-http:outbound-gateway request-channel="requestChannel1"
      reply-channel="replyChannel1" url-expression="headers.url"
      extract-request-payload="true" expected-response-type="java.lang.String" http-method="POST" charset="UTF-8"/>

      public class ShoppingListHeaderMapper extends DefaultHttpHeaderMapper {

      public void fromHeaders(MessageHeaders headers, HttpHeaders httpHeaders) {


      super.fromHeaders(headers, httpHeaders);


      But the header url Did not get added


      on the inteface of my gateway I added @header
      as described

      but got " Message headers is immutable" error .

      Can you please suggest how do i add headers??
      Last edited by Dheerja; Dec 20th, 2012, 04:57 AM.


      • #4


        • #5
          Hey Gary

          I have to add headers that are dynamically determined from the content .

          Any suggestions on how to do that??


          • #6
            Use an expression...

            <int:header-enricher input-channel="in" output-channel="out">
            	<int:header name="foo" expression="payload.someProperty"/>


            • #7
              Hey Gary

              I cant use Payload.
              I have my request body in payload
              Its a Post call with a Dynamic Url
              I wanted to put the url in the headers from my code so that i can fetch the value in the spring integration file


              • #8
                Well, your payload could be a wrapper class that contains the data for your headers as well as the request body in another property; after the header enricher, add a transformer (expression=payload.requestBody).

                If you don't want to do that, and want to manipulate the headers directly, write a @Transformer

                public Message<?> transform(Message<?> message) {
                      return MessageBuilder.fromMessage(message)
                        .setHeader("foo", "bar")
                        .setHeader("baz", "qux")