Announcement Announcement Module
Collapse
No announcement yet.
Setting HTTP headers Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting HTTP headers

    Hi,

    As my project grows, I run into this problem:

    Code:
        <int:header-enricher input-channel="inputChannel" output-channel="outputChannel">
                <int:header name="#{T(org.apache.http.HttpHeaders).AUTHORIZATION}" value="myAuthor"/>
                <int:header name="#{T(org.apache.http.HttpHeaders).CONTENT_TYPE}" value="#{T(org.springframework.http.MediaType).APPLICATION_XML_VALUE}"/>
                <int:header name="UUID" expression="payload.uuid.toUpperCase()"/>
        </int:header-enricher>
    And there are other input-output channel pairs which need to have the header set.

    How can I reuse this xml construct for other channel pairs?

    Currently every time I have a pair of in/out Channel, I have to replicate this header setting rigaormore.

    Is going back to a service activator approach better off? Looks like there is an opportunity I can just use a template method to 1. set the basic headers, 2. set specific headers based on the channel pair...

    Not to mention sometimes the input/output channel is in a chain, i.e.


    Code:
        <int:header-enricher>
                <int:header name="#{T(org.apache.http.HttpHeaders).AUTHORIZATION}" value="myAuthor"/>
                <int:header name="#{T(org.apache.http.HttpHeaders).CONTENT_TYPE}" value="#{T(org.springframework.http.MediaType).APPLICATION_XML_VALUE}"/>
                <int:header name="UUID" expression="payload.uuid.toUpperCase()"/>
        </int:header-enricher>
    But that does not happen often enough, so I guess I could replicate...


    Maybe in future we can have a section, in the SI blog or manual, mentioning how to organize a medium-to-big size project, config file import/reuse, etc.

  • #2
    Hello

    I think you can reach your requirements through this trick:
    HTML Code:
    <chain>
       <gateway request-channel="header-enricher-channel"/>
    </chain>
    So, here you have just only one config for <int:header-enricher>, but it should be just only with input-channel attribute.
    And when you need reuse it you place in your message flow the config <chain> -> <gatewawy>.
    http://static.springsource.org/sprin...hain-namespace

    Cheers,
    Artem

    Comment

    Working...
    X