简体   繁体   English

在业务流程内的Biztalk消息中创建文件

[英]Create a File in a Biztalk message inside a orchestration

I'm having some trouble sending a file by ftp from my BizTalk 2006RC. 我在从BizTalk 2006RC通过ftp发送文件时遇到麻烦。 The part the i struggle is to create a real file named "OPA0037" with only one line 我要做的工作是创建一个只有一行的名为“ OPA0037”的真实文件

"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. ftp部分之后的问题不是问题,我只是看不到如何从消息中创建文件...它只能在业务流程中。

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 由于我一直在思考可能出现的其他问题,因此该帖子引起了很大的关注-我怀疑您的关键部分将是最后一部分, 使用BizTalk中的FTP传输发送消息

Let us know how you get along... 让我们知道您的相处...

Creating a FlatFile message within an orchestration 在业务流程中创建FlatFile消息

In BizTalk you never create orchestration messages in any format other than XML. 在BizTalk中,您永远不会以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. 从BizTalk流程中创建FlatFile消息所需要做的是在设计时创建一个FlatFile模式,然后在运行时,生成该模式的实例,并通过具有BizTalk FlatFile汇编器的BizTalk发送端口将其发送出去。在组装阶段配置。

A FlatFile schema is simply an XML schema with special annotations that inform the BizTalk FlatFile assembler how to serialize XML to text. FlatFile模式只是具有特殊注释的XML模式,这些注释告知BizTalk FlatFile汇编程序如何将XML序列化为文本。

So, creating a FlatFile message within an orchestration is actually the same as creating any other document format within an orchestration. 因此,在业务流程中创建FlatFile消息实际上与在业务流程中创建任何其他文档格式相同。

Creating a message within an orchestration 在业务流程中创建消息

So then, how to create a new message within a BizTalk orchestration? 那么,如何在BizTalk业务流程中创建新消息呢?

To avoid recreating the wheel, here is a link to a rather classic post by Matt Meleski about just this topic. 为了避免重新创建轮子, 这里是Matt Meleski关于这个主题的相当经典的文章的链接。

To summarise what Matt says, to create a new instance of a message in BizTalk you have four main options available to you: 总结一下Matt所说的,要在BizTalk中创建消息的新实例,您可以使用四个主要选项:

  1. Create a new message from an existing message using a BizTalk map 使用BizTalk映射从现有消息创建新消息
  2. Assign one message from another message within a Message Assignment shape 在“消息分配”形状中分配另一条消息中的一条消息
  3. Utilise an XML.XMLDocument variable within a Message Assignment shape. 在“消息分配”形状中使用XML.XMLDocument变量。
  4. Use a .NET helper class that returns a message of the required type. 使用.NET帮助程序类返回所需类型的消息。

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. 对于需要创建一个简单的单行文档的情况,映射选项(1)或XMLDocument选项(3)可能会带您到达所需的位置。

Sending a message using the FTP transport in BizTalk 使用BizTalk中的FTP传输发送消息

I think this could be your problem - how to send an FTP message, or FlatFile format in BizTalk with a specified filename. 我认为这可能是您的问题-如何在BizTalk中使用指定的文件名发送FTP消息或FlatFile格式。

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 1.设置ReceivedFileName并使用%SourceFileName%宏

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. 在研究我的答案时,我认为这种方法不适用于FTP,但是我发现了一个生产示例,正是在该示例中。 Give it a go. 搏一搏。

In the orchestration Construct Message shape, add a Message Assignment shape. 在业务流程“ Construct Message形状中,添加“ Message Assignment形状。

In that message assignment shape, you can set the FILE.ReceivedFileName property for your flat file message as so: 在该消息分配形状中,可以将平面文件消息的FILE.ReceivedFileName属性设置为:

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: 在静态发送端口中,使用目标文件名指定FTP适配器,例如:

%SourceFileName%.txt %SourceFileName%.TXT

And the FTP adapter then replaces the %SourceFileName% macro, giving you a filename like whateverFileNameYouWant.txt 然后,FTP适配器将替换%SourceFileName%宏,从而为您提供一个诸如whatFileNameYouWant.txt之类的文件名

In your send port you then need to specify a send pipeline that contains a FlatFile assembler for your flatfile format. 然后,在发送端口中,您需要指定一个发送管道,该管道包含用于Flatfile格式的FlatFile汇编程序。

2. Use a dynamic send port with a programatic call to a pipeline 2.使用动态发送端口和对管道的编程调用

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. 问题是要在BizTalk中发送具有指定文件名的FTP消息,您需要使用动态发送端口。 BUT with a dynamic send port you are limited to a pass through pipeline, so you have nowhere to specify your FlatFile assembler. 但是具有动态发送端口的您只能使用直通管道,因此您无处指定FlatFile汇编程序。

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): 要创建一个动态发送端口来创建文件名,您要在业务流程消息分配形状中遵循以下代码(由Christof Claessens的博客提供):

//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? 那么,如何使此动态发送端口发送出Flatfile格式的文件呢?

That trick is discussed here . 这个技巧在这里讨论。 What you need to do call a send pipeline from within an Orchestration (a new capability in BizTalk 2006). 您需要做的就是在业务流程中调用发送管道(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. 然后,使用FlatFile格式的文本填充业务流程消息msg_OUtput_FF。 BizTalk still thinks of this as an XML document, but it isn't really. BizTalk仍将其视为XML文档,但实际上并非如此。 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: 也许您可以尝试两种最常见的选择:

  • Send the message through a send port and configure that port to use the FILE or FTP adapter. 通过发送端口发送消息,并将该端口配置为使用FILE或FTP适配器。 If the file is a flat file with delimited structure (as in the sample), you should create the corresponding Flat File Schema and a Send pipeline wich includes the Flat File Assembler in its assemble stage. 如果文件是具有分隔结构的平面文件(如示例中所示),则应创建相应的平面文件架构,并且发送管道在其组装阶段将平面文件汇编器包括在内。 Then, configure your physical port to use that pipeline. 然后,配置您的物理端口以使用该管道。

Look at this walkthrough from msdn on creating Flat Files: http://msdn.microsoft.com/en-us/library/aa577898(BTS.20).aspx 请参阅msdn关于创建平面文件的演练: http : //msdn.microsoft.com/zh-cn/library/aa577898(BTS.20).aspx

  • Create a .NET class library with the code for writing the physical file and use it from the Orchestration. 使用编写物理文件的代码创建一个.NET类库,并从Orchestration中使用它。 You´ll neeed to add the class library assembly as a reference to the BTS project. 您将需要添加类库程序集作为对BTS项目的引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM