Showing posts with label FTP Adapter. Show all posts
Showing posts with label FTP Adapter. Show all posts

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.