Ask Your Question
4

How can a custom header be added to the MarshallingWebServiceOutboundGateway in SI?

asked 2022-11-17 11:00:00 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2021-06-03 10:00:00 +0000

nofretete gravatar image

To add a custom header to the MarshallingWebServiceOutboundGateway in Spring Integration, you can use the HeaderEnricher component. The HeaderEnricher allows you to add, modify or remove headers of a message.

Here is an example configuration:

<int:header-enricher input-channel="enrichChannel" output-channel="outboundChannel">
    <int:header name="Custom-Header" value="customValue"/>
</int:header-enricher>

<int-ws:marshaller id="marshaller" />

<int-ws:outbound-gateway uri="http://example.com"
                         marshaller="marshaller"
                         expected-response-type="java.lang.String"
                         reply-channel="responseChannel">
    <int-ws:request-handler-advice-chain>
        <ref bean="retryAdvice" />
    </int-ws:request-handler-advice-chain>
</int-ws:outbound-gateway>

In this configuration:

  • The HeaderEnricher component is used to add the custom header "Custom-Header" with the value "customValue" to the message.
  • The message is sent to the MarshallingWebServiceOutboundGateway for outbound communication. The reply-channel is set to "responseChannel".
  • A request-handler-advice-chain is added, which can be used to add additional behavior to the outbound gateway. In this example, the retryAdvice is used to retry the outbound call in case of failures.

With this configuration, the custom header will be added to the message sent to the web service.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-11-17 11:00:00 +0000

Seen: 10 times

Last updated: Jun 03 '21