I can print individual transport headers in the WSO2 ESB with the following code inside a sequence:
<log level="custom">
<property name="oneHeader" expression="$trp:FILE_NAME"/>
</log>
But I need to print all available transport properties. There is a axis2 property called "[TRANSPORT_HEADERS][1]", but when printing this property it is always empty.
<log level="custom">
<property name="allHeaders" expression="get-property('axis2','TRANSPORT_HEADERS')"/>
</log>
Because I don't know all header names, I need to know how to print all transport headers?
I don't know how to print all the transport properties, but if you set a breakpoint in your sequence and enable debugging as described in https://docs.wso2.com/display/EI611/Debugging+Mediation, you can find all the transport properties in the 'Variables' tab.
You can conveniently access HTTP headers, which technically are transport headers in WSO2 ESB, by using XPath variables. The easiest way to read an HTTP header named X-EMPID is by using the following XPath: $trp:X-EMPID, where the $trp prefix indicates that the part following the colon is the name of a transport property. To log the header value you could use the following log mediator:
To set the property myProperty to the value of X-EMPID HTTP header (which is already stored in a transport property) you would use the property mediator:
The functionality is documented on the WSO2 site.
for more.
We can't log this property using property mediator since this is an internal JAVA Map in axis2-transports. Hence We may need to use a class mediator for this purpose.
Following is a sample one.
You may place the class mediator jar directly in EI_HOME/lib or ESB_HOME/repository/components/lib and use the following config
in the proxy or API after adding following to log4j.properties file
Please refer here for further details : https://medium.com/@nirothipanram/wso2-ei-print-all-transport-headers-12aabb4027cc