Pregunta

I am trying to add a custom header in Mule's HTTP endpoint:

<flow name="flow">
    <poll frequency="60000">
        <http:outbound-endpoint
            address="http://user:pass@example.com"
            followRedirects="true" method="GET" exchange-pattern="request-response">
            <properties>
                <spring:entry key="CUSTOM-HEADER-NAME" value="custom-header-value" />
            </properties>
        </http:outbound-endpoint>
    </poll>
    <echo-component />
</flow>

But this way of using <spring:entry> element for adding custom header does not seem to work.

I tried replacing

<properties>
    <spring:entry key="CUSTOM-HEADER-NAME" value="custom-header-value" />
</properties>

with

<property key="CUSTOM-HEADER-NAME" value="custom-header-value"/>

But that does not work either. I am not seeing any error, but the response I am getting is the one which I would get without the custom header.

Am I following the right way to add custom headers? I am using Mule 3.2.0.

¿Fue útil?

Solución 2

Got it working using <message-properties-transformer>:

<http:outbound-endpoint
    address="http://user:pass@example.com"
    followRedirects="true" method="GET" exchange-pattern="request-response">
    <message-properties-transformer
        scope="outbound">
        <add-message-property key="CUSTOM-HEADER-NAME"
            value="custom-header-value" />
        </message-properties-transformer>
</http:outbound-endpoint>

Otros consejos

If you want to add custom header name from Mule .. there are 2 ways :-

1) Use Set property in your flow like :-

< set-property propertyName="Custom Header"  doc:name="Set Custom Header" value="Here Set your Message"/ >

2) Use SOAP intercepter where you have to create a java class HttpHeaderInterceptor.java and then refer in the intercepter using Spring bean.. Please refer this :- http://java.dzone.com/articles/adding-http-headers-soap

Either way you can follow ... easy way is using set Property in mule flow Just before CXF SOAP component .... The result you can see in SOAP UI in header section in response... Hope this help

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top