自定义组件:编写BizTalk 自定义管道组件的一个意外错误



作者:郑佐 2006-11-28
假设有个名为Zhengzuo.BizTalk.Pipelines组件项目用来实现个BizTalk 2006自定义管道组件

以下是笔者编写自定义接收管道组件段不完整代码
[ComponentCategory(CategoryTypes.CATID_PipelineComponent)]
[ComponentCategory(CategoryTypes.CATID_Any)]
[ComponentCategory(CategoryTypes.CATID_Validate)]
[ComponentCategory(CategoryTypes.CATID_DisassemblingParser)]
[.Runtime.InteropServices.Guid(\"7EDA198E-6FD8-4046-A974-1C8BF55C3B93\")]
public BoxUpMessageComponent :
IComponent,
IBaseComponent,
IComponentUI,
IPersistPropertyBag,
IDisassemblerComponent
{
private const description = \"管道解码器编写人:郑佐\\n编写时间:2006-08-1\";
private const name = \"某某管道组件\";
private const version = \"1.0.0.0\";
}

编译Zhengzuo.BizTalk.Pipelines项目成功输出到D:\\Program Files\\Microsoft BizTalk Server 2006\\Pipeline Components目录生成组件为Zhengzuo.BizTalk.Pipelines.dll

在解决方案中新建个名为BizTalkTestBizTalk项目添加个发送管道取名为SendPipeline1.btp打开该发送管道进行编辑把“某某管道组件”从工具箱拉到解码位置(如果在工具箱中没有找到“某某管道组件”在工具箱上右键点击“选择项”菜单在显示窗口上选择BizTalk管道组件选项卡选中“某某管道组件”添加)
pipecomponent.jpg


编译BizTalkTest项目出现连串如下:
11 常量中有换行符
12 意外“:”
13 意外
14 常量中有换行符
15 应输入 ;
16 类、结构或接口成员声明中标记“:”无效
17 类、结构或接口成员声明中标记“>”



在BizTalkTest项目文件目录下复制SendPipeline1.btp文件并修改文件名为SendPipeline1.xml使用IE或FireFox打开显示内容如下
<?xml version=\"1.0\" encoding=\"utf-16\"?>
<Document xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" PolicyFilePath=\"BTSReceivePolicy.xml\" MajorVersion=\"1\" MinorVersion=\"0\">
<Description />
<Stages>
<Stage CategoryId=\"9d0e4103-4cce-4536-83fa-4a5040674ad6\">
<Components>
<Component>
<Name>Zhengzuo.BizTalk.Pipelines.BoxUpMessageComponent</Name>
<ComponentName>某某管道组件</ComponentName>
<Description>管道解码器编写人:郑佐
编写时间:2006-08-1</Description>
<Version>1.0.0.0</Version>
<Properties />
<CachedDisplayName>某某管道组件</CachedDisplayName>
<CachedIsManaged>true</CachedIsManaged>
</Component>
</Components>
</Stage>
<Stage CategoryId=\"9d0e4105-4cce-4536-83fa-4a5040674ad6\">
<Components>
<Component>
<Name>Microsoft.BizTalk.Component.FFDasmComp</Name>
<ComponentName>平面文件拆装器</ComponentName>
<Description>流平面文件拆装器组件</Description>
<Version>1.0</Version>
<Properties>
<Property Name=\"HeaderSpecName\" />
<Property Name=\"DocumentSpecName\">
<Value xsi:type=\"xsd:\">BizTalkTest.SendPipeline1</Value>
</Property>
<Property Name=\"TrailerSpecName\" />
<Property Name=\"PreserveHeader\">
<Value xsi:type=\"xsd:boolean\">false</Value>
</Property>
<Property Name=\"ValidateDocumentStructure\">


<Value xsi:type=\"xsd:boolean\">false</Value>
</Property>
<Property Name=\"RecoverableInterchangeProcessing\">
<Value xsi:type=\"xsd:boolean\">false</Value>
</Property>
</Properties>
<CachedDisplayName>平面文件拆装器</CachedDisplayName>
<CachedIsManaged>true</CachedIsManaged>
</Component>
</Components>
</Stage>
<Stage CategoryId=\"9d0e410d-4cce-4536-83fa-4a5040674ad6\">
<Components />
</Stage>
<Stage CategoryId=\"9d0e410e-4cce-4536-83fa-4a5040674ad6\">
<Components />
</Stage>
</Stages>
</Document>

注意到xml文件红色标注部分对应Zhengzuo.BizTalk.Pipelines组件项目中代码为
private const description = \"管道解码器编写人:郑佐\\n编写时间:2006-08-1\";
修改以上代码为
private const description = \"管道解码器编写人:郑佐编写时间:2006-08-1\";

修改btp发送管道重新添加“某某管道组件”编译BizTalkTest项目成功查看btp文件xml结构为
<Description>管道解码器编写人:郑佐编写时间:2006-08-1</Description>

可见由于“\\n”导致项目编译失败这个算不算是BizTalk Server 2006开发中个小bug?
Tags:  biztalk 自定义组件

延伸阅读

最新评论

发表评论