Thursday, September 25, 2008

FTP file name: Both Get fileName and dynamic Put filename

How did it make into my workspace?

What else but a requirement.
A file is dynamically created based on the web service message received.
The file that needs to be FTPed has a name, that is dynamic.
The file name is one of the fields in the message received.
Well this was about Put.

How the hell did Get file name come to my workspace?

Well it was not a requirement in my project. But was a help that I did for a friend.
This person wanted to read files from a server.
And drop this off to another server after some enrichment's to the content.
And wanted the Get and Put file names to match.

So this adds a new thing of getting the filename of the file that was read from FTP directory.

How does it work?

If you have created FTP Get and Puts you should see
ftpAdapterInboundHeader.wsdl and ftpAdapterOutboundHeader.wsdl file in your workspace.

These are the 2 key file to get this cracking.
Both of these have a element called fileName.

What to do with this element?

You have to either play with these elements to get the work done.
To play with these elements you first need to create a variable from the wsdl.

How to get the file name of the get file?

Just use the variable that you have created from the ftpAdapterInboundHeader.wsdl.
Read the fileName element. Yes it is that easy.

How to assign file name to put file?

Well nothing different from the above one.
But this time round you need not read but assign value to the fileName element.
The variable that you have created from the ftpAdapterOutboundHeader.wsdl, use that.

Assign the file name to the fileName element in this variable.
Thatz it. You have done it.

What Does it do in the background?

What you are trying to do here is either read or write to the FTP Adapter Header Message.

For Inbound messages the header has the fileName, FTP server and FTP port.
For Outbound message the header has the fileName.

You can play with these.
From Inbound message you can read the values.
For Outbound if you populate these values the Adapter will behave accordingly.

8 comments:

Anonymous said...

Very Good one and explained well. This is applicable to other Adapters as well. We did this for File Adapters.

Keep sharing your learnings.

Anonymous said...

Can I get the archived file name in BPEL Process, once the file is archived.

Anonymous said...

Why don't you post the code? It would be helpful for others.

In most of your blog you talk about the problems you had faced but the solution part is very small. Sometimes it is frustating to read your blog.

Kalidass Mookkaiah said...

Unfortunately I had started this blog as a place where I could put things that I am not able to find easily or find at all.

So the audience for this was only my self for long time. Till some my colleagues found it useful and suggested that I should increase my scope. I never wanted my blog to be alternative to developers guide but more like a quick hints that some one can take away to a developers guide for digging.

Unfortunately if you are looking for lot of code detailing every step, I suggest using developers guide for reference.
And a bit of experiments would help.

MK

Anonymous said...

Thank you Kalidas , I used the trick to put a file Name to outbound header

Thanks
Ganesh

Anonymous said...

Hey kalidas, how does this works in SOA11g? when we create a FTP or File in SOA 11g I don't see any Outbound or Inbound header wsdls
How to overcome the usage of 10g with 11g?

Anonymous said...

Hey Kalidas I got the answer for my question....
You have to go to the invoke and its properties...

Thanks though...

Anonymous said...

Hi,

I have a requirement like this. I need to monitor 3 different FTP servers and once the file is placed in these servers, need to get the file using FTP adapter. I have to do this using single BPEL process. Can you please suggest me a way to do this ?

Regards