BizTalk -->

by muyanpeng

导航

BizTalk 动态绑定输出消息名称 (Using the %SourceFileName% macro to create a custom send file name in BizTalk 2006)

首先建立一个 Biztalk Project :create a custom send file name

创建消息: Schema1.xsd

<?xml version="1.0" encoding="utf-16" ?> 
 
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://create_a_custom_send_file_name.Schema1" targetNamespace="http://create_a_custom_send_file_name.Schema1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
 
<xs:element name="Root">
 
<xs:complexType>
 
<xs:sequence>
  
<xs:element name="a" type="xs:string" /> 
  
<xs:element name="b" type="xs:string" /> 
  
</xs:sequence>
  
</xs:complexType>
  
</xs:element>
  
</xs:schema>

创建流程:BizTalk Orchestration1.odx
输入消息: Message1 --> message type:Schema1.xsd
输出消息: Message2 --> message type:Schema1.xsd




在中间构造输出消息的部分添加如下代码:
Message_2 = Message_1;
Message_2(FILE.ReceivedFileName) 
= System.DateTime.Now.ToString("yyyy-MM-dd tt hh-mm-ss");

图示:



保存 关联*.snk 发布工程 (略)

配置:
在消息的发送端口 选用File Adapter 配置如图:
在File name处写入:
%SourceFileName%




启动Application 测试。。

输出结果:



OK 搞定

源码下载

补充一个老外写的表格:

Macro name

Substitute value

%datetime%

Coordinated Universal Time (UTC) date time in the format YYYY-MM-DDThhmmss (for example, 1997-07-12T103508).

%datetime_bts2000%

UTC date time in the format YYYYMMDDhhmmsss, where sss means seconds and milliseconds (for example, 199707121035234 means 1997/07/12, 10:35:23 and 400 milliseconds).

%datetime.tz%

Local date time plus time zone from GMT in the format YYYY-MM-DDThhmmssTZD, (for example, 1997-07-12T103508+800).

%DestinationParty%

Name of the destination party. The value comes from message the context property BTS.DestinationParty.

%DestinationPartyID%

Identifier of the destination party (GUID). The value comes from the message context property BTS.DestinationPartyID.

%DestinationPartyQualifier%

Qualifier of the destination party. The value comes from the message context property BTS.DestinationPartyQualifier.

%MessageID%

Globally unique identifier (GUID) of the message in BizTalk Server. The value comes directly from the message context property BTS.MessageID.

%SourceFileName%

Name of the file from where the File adapter read the message. The file name includes extension and excludes the file path, for example, foo.xml. When substituting this property, the File adapter extracts the file name from the absolute file path stored in the FILE.ReceivedFileName context property. If the context property does not have a value, for example, if message was received on an adapter other than File adapter, then the macro will not be substituted and will remain in the file name as is (for example, C:"Drop"%SourceFileName%).

%SourceParty%

Name of the source party from which the File adapter received the message.

%SourcePartyID%

Identifier of the source party (GUID). The value comes from the message context property BTS.SourcePartyID.

%SourcePartyQualifier%

Qualifier of the source party from which the File adapter received the message.

%time%

UTC time in the format hhmmss.

%time.tz%

Local time plus time zone from GMT in the format hhmmssTZD (for example, 124525+530).