Is it possible to pass all incoming headers in requst via Service Callout ?

Not applicable

We have a scenario where in we are using service callout to make backend calls , so we need to pass all the request headers to backend call made via service callout.

It is very difficult to use copy tag for all the headers values.

0 1 1,895
1 REPLY 1

I think you can do this with a combination of AssignMessage and ServiceCallout policies.

The following AssignMessage will create a new request variable, copying all the headers from the incoming request:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1">
    <DisplayName>Assign Message-1</DisplayName>
    <Properties/>
    <Copy source="request">
        <Headers/>
    </Copy>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="true" transport="http" type="request">myRequest</AssignTo>
</AssignMessage>

Then this ServiceCallout policy uses that request to hit http://httpbin.org/headers. If you run these in trace, you'll see the response from the callout indicates the incoming headers were passed to the target of the service callout:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="Service-Callout-1">
    <DisplayName>Service Callout-1</DisplayName>
    <Properties/>
    <Request clearPayload="true" variable="myRequest">
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    </Request>
    <Response>calloutResponse</Response>
    <HTTPTargetConnection>
        <Properties/>
        <URL>http://httpbin.org/headers</URL>
    </HTTPTargetConnection>
</ServiceCallout>