Use of client IP or X-Forwarded-For as a parameter that gets passed to a XSLT Transformation

Not applicable

I have been trying to create a parameter using the X-Forwaded-For entry and pass that parameter to a XSLT transformation to be used as a part of the payload going to the back end service. Below is my assign message. So far I have had no luck getting this set that I know of. In the long run I would like it to be more generic so that it can be used for multiple XSLT transformations.

<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-1"> 
  <DisplayName>AM-1</DisplayName> 
  <XSL name="SubscriberInquiry"> 
    <DisplayName>Set-ClientIp</DisplayName> 
    <FaultRules/> 
    <Properties/> 
    <OutputVariable>request.content</OutputVariable> 
    <Parameters ignoreUnresolvedVariables="false"> 
      <Parameter name="clientIp" ref="x-forwarded-for"/> 
    </Parameters> 
    <ResourceURL>xsl://SubscriberInquiry_req.xsl</ResourceURL> 
    <Source>request</Source> 
  </XSL> 
</AssignMessage>
0 1 291
1 REPLY 1

Hi Rick

First, Something is not right there. I think you are mixing two different policies.

The schema for AssignMessage is ... like this:

<AssignMessage name='AM-1'>
  <AssignTo createNew='false' transport='http' type='response'></AssignTo>
  <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
  <Set>
    <Payload contentType='application/json'>{"foo" : "bar" }</Payload>
    <StatusCode>200</StatusCode>
    <ReasonPhrase>OK</ReasonPhrase>
  </Set>

  <AssignVariable>
    <Name>customResponse_assigned</Name>
    <Value>true</Value>
  </AssignVariable>

</AssignMessage>

The configuration for XSL is different. XSL is the top-level element.

<XSL name='XSL-1'>
  <Source>someMessageVariable</Source>
  <OutputVariable>transformedContent</OutputVariable>
  <ResourceURL>xsl://mysheet.xsl</ResourceURL>
  <!--
      Parameters are optional. reference them in the XSL as:
      <xsl:param name="pwd" select="''"/>
      <xsl:param name="converted" select="''"/>
  -->
  <Parameters ignoreUnresolvedVariables='true'>
    <Parameter name='paramname' ref='context_variable_here'/>
  </Parameters>
</XSL>


Second, I think the name of the context variable you want to reference in order to get the x-forwarded-for header is

request.header.x-forwarded-for .