Search code examples
xmlxsltxsdwsdlmule

How to pass a logger message value to .xslt file in mule


In configuration.xml file I implemented a flow for publishing out a wsdl, during the way I put a logger that return Client's IP address. this is my code:

<logger message="#[groovy:message.getInboundProperty('MULE_REMOTE_CLIENT_ADDRESS')]" level="INFO" doc:name="Logger"/>

Now I want to transfer(pass) ip address to my .xslt file? How can I do it?


Solution

  • If you're using Mule 3.3, you can utilize MEL and simplify logger statement like this:

    <logger message="#[message.inboundProperties['MULE_REMOTE_CLIENT_ADDRESS']]" level="INFO" doc:name="Logger"/>
    

    To pass IP address to XSLT, store it in a variable and pass that.

    <set-variable variableName="remoteClientAddress" value = "#[message.inboundProperties['MULE_REMOTE_CLIENT_ADDRESS']]"/>
    

    Display with logger

      <logger message="Remote client address is------> #[remoteClientAddress]" level="INFO" doc:name="Logger"/>
    

    Pass it to XSLT as:

       <xm:xslt-transformer xsl-file="xsltFileName.xslt">
            <xm:context-property key="remoteClientAddress" value="#[remoteClientAddress]"/>
        </xm:xslt-transformer>
    

    In your XSLT, declare a param variable

    <xsl:param  name="remoteClientAddress" />
    

    and then use this variable as

    <xsl:value-of select="$remoteClientAddress" />