I'm having some trouble sending a file by ftp from my BizTalk 2006RC. The part the i struggle is to create a real file named "OPA0037" with only one line
"OPA0037;TEST;;;"
that it after the ftp part isn't a problem i juste don't see how to create a file from a message... It can only be in the orchestration.
any help any idea is welcomed! thanks alot!!
It isn't clear exaclty what you are having trouble with here so I'm going to go over each step you describe and cover the various options. Hopefully one of these points addresses your problem.
The post got quite involved as I kept thinking of possible extra issues - I suspect the key section for you will be the last one Sending a message using the FTP transport in BizTalk
Let us know how you get along...
In BizTalk you never create orchestration messages in any format other than XML.
What you need to do to create a FlatFile message from within a BizTalk orchestration is to create a FlatFile schema at design time and then at runtime, generate an instance of this schema and send it out through a BizTalk send port that has the BizTalk FlatFile assembler configured in the assemble stage.
A FlatFile schema is simply an XML schema with special annotations that inform the BizTalk FlatFile assembler how to serialize XML to text.
So, creating a FlatFile message within an orchestration is actually the same as creating any other document format within an orchestration.
So then, how to create a new message within a BizTalk orchestration?
To avoid recreating the wheel, here is a link to a rather classic post by Matt Meleski about just this topic.
To summarise what Matt says, to create a new instance of a message in BizTalk you have four main options available to you:
As with most things, each of the options above could have its own lengthy post written about it.
Probably for your case of needing to create a simple one line document, either the mapping option (1) or the XMLDocument option (3) will get you where you need to go.
I think this could be your problem - how to send an FTP message, or FlatFile format in BizTalk with a specified filename.
There are a number of approaches to this. I'll give two, hopefully the first should work but you can then fall back to the second.
1. Set the ReceivedFileName and use the %SourceFileName% macro
While researching my answer, I didn't think that this approach would work for FTP, but I found a production example where I'm doing just this. Give it a go.
In the orchestration Construct Message
shape, add a Message Assignment
shape.
In that message assignment shape, you can set the FILE.ReceivedFileName
property for your flat file message as so:
yourFlatFileMessage(FILE.ReceivedFileName) = whateverFileNameYouWant;
This sets a context property that will then be used when you wire a static send port to your orchestration port. In your static send port you specify the FTP adapter with a target file name like:
%SourceFileName%.txt
And the FTP adapter then replaces the %SourceFileName% macro, giving you a filename like whateverFileNameYouWant.txt
In your send port you then need to specify a send pipeline that contains a FlatFile assembler for your flatfile format.
2. Use a dynamic send port with a programatic call to a pipeline
If the method above doesn't work then you will need to use a dynamic send pipeline.
The problem is that to send a FTP message with a specified file name in BizTalk, you need to use a dynamic send port. BUT with a dynamic send port you are limited to a pass through pipeline, so you have nowhere to specify your FlatFile assembler.
To create a dynamic send port that creates the file name you want to following code in an orchestration message assignment shape (courtesy of Christof Claessens' blog):
//Set dynamic ports location:
orchprtSndMyMessagePort(Microsoft.XLANGs.BaseTypes.Address) = "ftp://myserver/mydirectory/myfilename.xml";
//Set context on the message you want to send:
msgMyMessage(FTP.UserName) = "myFTPUsername";
msgMyMessage(FTP.Password) = "myFTPPassword";
msgMyMessage(BTS.RetryCount) = 20;
msgMyMessage(BTS.RetryInterval) = 2;
So, how to then make this dynamic send port send out a flatfile format file?
That trick is discussed here . What you need to do call a send pipeline from within an Orchestration (a new capability in BizTalk 2006).
The code to do that is below:
//PipeMsg is a variable of type: Microsoft.XLANGs.Pipeline.SendPipelineInputMessages
PipeMsg = new Microsoft.XLANGs.Pipeline.SendPipelineInputMessages();
PipeMsg.Add(<MessageToAssemble>);
Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteSendPipeline(typeof (<fullyQualifiedNameofSendPipline>),PipeMsg,msg_Output_FF);
This then populates your orchestration message msg_OUtput_FF with your FlatFile formatted text. BizTalk still thinks of this as an XML document, but it isn't really. When you send this out through you dynamic send port with its passthrough pipeline, you should see the flatfile contents.
Maybe you can try two of the most common options:
Look at this walkthrough from msdn on creating Flat Files: http://msdn.microsoft.com/en-us/library/aa577898(BTS.20).aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.