Blog maintained by TechnoGems

Sunday, November 23, 2008

How to set the name of the file dynamically during transformation time in ESB fileAdaptor

Oracle ESB provides header functions that allows designers to access inbound and outbound header functions. The following are the functions available.

1. String getRequestHeader(String xpathExpression,String namespaceDecl)
2. void setOutboundHeader(String xpathExpression,String value, String namespaceDecl)
3. String getInboundResponseHeader(String xpathExpression,String namespaceDecl)
4. void setResponseHeader(String xpathExpression,String value, String namespaceDecl)
Where,
xpathExpression : XPath expression to get/set
value : value to be set for the xpathExpression
namespaceDecl : namespace declarations in the form ‘prefix=namespace;’


You can use the following code snippet in your transformation xslt to set the name of the file that is about to written by the ESB File adaptor. This overrides the name given in the design time.

<xsl:variable name="SET_OUTFILENAME"
select="ehdr:setOutboundHeader('/fhdr:OutboundFileHeaderType/fhdr :fileName', $GET_INFILENAME, 'fhdr=http://xmlns.oracle.com/pcbpel/adapter/file/;')"/>


The variable GET_INFILE is the name of the input file name as referred in the previous post.
If you like an example project, you can download it from oracle site here The sample project is under HeaderSupportDemo folder.

No comments: