Oracle Service Bus, set filename for business service

And ex-colleague asked me to give a little help on setting the filename which was getting created by his Oracle Service Bus flow.

Create a new business service with file transport and set the correct location of the file with his prefixes.
In this wizard we can only set the prefixes and the location of the file, so no option to set the filename by use of some expression.

For the interface of the proxy service i used the almighty helloworld wsdl, and the content of this request we will put in the file.
The name of the file will have the value of the first argument (‘arg0’) on the ‘hello’ operation (in this case ‘John’ with the prefixes).

<hel:hello xmlns:hel="http://hello.service.xenta.nl/">
    <!--Optional:-->
    <arg0>John</arg0>
</hel:hello>

In the flow route to the business service (or use the option in the ide to create a proxy service from a business service).

Open the route and the only thing we need in here is the activity ‘Set Transport Headers’.

Since we’re routing to a business service which makes use of the file transport we can make use of the ‘fileName’ property of the ‘file’ part.
If we would have create a business service for some other transport we could also make use of all the other properties to override values in the routing.
Just browse the list, a lot of usefull properties to use.

We select the ‘fileName’ of the ‘file’ part, and at the right we will now be able to use an expression to override the default generated filename by the Oracle Service Bus.
In our case we will select ‘Set Header to’ and use the expression ‘$body/hel:hello/arg0/text()’.

Save the flow and run the proxy service. Using the payload from above the next file will be created ‘c:\test\mytestfileJohn’. Prefix + ‘John’ from the payload.

Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

8 Responses to “Oracle Service Bus, set filename for business service”

commenter

Hi Eric,
Thanks for nice article

Mani

commenter

thanks

commenter

Hi Eric,

I’d like to ask you regarding the write-to-file using BS as your tutorial.

I’ve created a PS that call the BS (to write file), but since the BS’s response was set to NONE, my PS return an error “A callout can not invoke a one-way operation”.

Do you have any idea to solve the problem?
The purpose of the PS I’ve create is simply to pass the value of the file and it’s name to the BS.

Thanks in advanced.

commenter

Hi!

If oneway/req-response is the only problem you could just use a publish (which will accept the oneway interface)

commenter

Helped me with one of my problems.. nice article.. thanks..
if i want to expand on this idea and “over write” the file that is being created, which is, the next time this service runs, it should create mytestfileJohn and not mytestfileJohn_1

How do I do that?
Thanks in advance.

commenter

Hmm interesting. Couldn’t find any pointers in the documentation on this.
You could try using a jca file adapter, see : http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/adptr_file.htm
then using a dynamic filename property on that, and put the “constant” string for the filename over there. The wizzard will let you give a filename pattern with a ‘unique’ part in the filename (%SEQ%, for example), overrule this with setting the jca.file.Filename property to your ‘default’ filename. Not sure if it would work, but worth a shot.

commenter

Hi Eric,
I am working on OSB 11G (OEPE), and I put on “set to header” the value ‘$body/fil:MoveRequest/fileName/text()’. and the file name in FTP side is text() instead of the value in fileName.

thank you for your advice.

Tantely

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Website:
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>