In Oracle Service Bus it’s relative easy to get the filename which has been processed by the proxy service.
On the $inbound context variable we can use the next xpath expression to get file uri
[sourcecode language=”xml”]
$inbound/ctx:transport/ctx:request/tp:headers/file:fileName
[/sourcecode]
this will give us :
[sourcecode language=”xml”]
[/sourcecode]
Now i was struckling a bit on how to get just the filename from this url.
Since i couldn’t find any instring function in the bea xqueury function list i couldn’t use any construction like (without the sql commands)
[sourcecode language=”sql”]
select substr(‘/tmp/testfile/test.xml’,instr(‘/tmp/testfile/test.xml’,’/’,-1)+1)
from dual;
[/sourcecode]
In this case the function tokenize can be used :
[sourcecode language=”xml”]
tokenize($inbound/ctx:transport/ctx:request/tp:headers/file:fileName, “/”)[last()]
[/sourcecode]
this will give me the last token in the list which is split up by the “/” sign, with as result “test.xml”.
In case your running it on a windows environment don’t forget to escape the backslash
[sourcecode language=”xml”]
tokenize($inbound/ctx:transport/ctx:request/tp:headers/file:fileName, “\\”)[last()]
[/sourcecode]
Original blog
3 Responses to “Oracle Service Bus, file transport, get filename from url”
[…] Original blog […]
Hi Eric,
R u get the output for this article.
Thanks
Mani
[…] http://www.xenta.nl/blog/2010/01/20/oracle-service-bus-file-transport-get-filename-from-url/ […]