Monday, February 4, 2008

Receiveing a File from a File or Ftp Adapter

I have an orchestration, receiving an XML-file from via the File Adapter. I need the filename to store in a database.
When placing the project in the production environment, we decided to use the FTP adapter instead of the File Adapter.
With BizTalk, It should be easy to change the receive ports.

I used in my orchestration line of codes like ReceiveXmlMessage(FILE.ReceivedFileName), but when changing the File Adapter to FTP adapter in the BizTalk Administration Console, something went wrong.

- Create a variable: fileName in your Orchestration
- Add an Expression Shape to you Orchestration
- Add the following Code into the expression shape:

tempString = "UNKNOWN";
if(FILE.ReceivedFileName exists ReceiveXmlMessage)
fileName =ReceiveXmlMessage(FILE.ReceivedFileName);
else if(FTP.ReceivedFileName exists ReceiveXmlMessage)
fileName =ReceiveXmlMessage(FTP.ReceivedFileName);

Not working Solutions:
I thought the following code would work, but I received an error saying that ReceiveXmlMessage(FTP.ReceivedFileName) was empty while using the File Adapter.

Not working code:
fileName = ReceiveXmlMessage(FILE.ReceivedFileName) + ReceiveXmlMessage(FTP.ReceivedFileName)

No comments: