biztalk定制管道组件(pipeline component)的调试、部署

(2007-9-25日更新)

一、 定制Pipeline componentassembly的部署

定制Pipeline componentassembly不一定要放在GAC中,可以放在<biztalk install directory>/Pipeline Components目录下,但是这时定制Pipeline component所引用的其它assembly必须也放在此目录中。

如果把定制Pipeline componentassembly放到GAC中,那么定制Pipeline component所引用的其它assembly必须也放在GAC中,否则定制Pipeline component不知道去哪找到它所引用的其它assembly

当定制Pipeline componentassemblyGAC<biztalk install directory>/Pipeline Components目录下有存在,那么优先使用<biztalk install directory>/Pipeline Components目录下的assembly

二、 定制Pipeline component的调试

无论把定制Pipeline componentassembly放到GAC中还是放在<biztalk install directory>/Pipeline Components目录下,都可以对定制Pipeline componen进行源代码级别调试。

为了方便,一般把Pipeline component项目的输出路径指向<biztalk install directory>/Pipeline Components目录。

1、 调试已部署的Pipeline component

对于已经部署的biztalk项目,项目中使用到了定制的Pipeline component,可以在VS2005环境下对Pipeline component进行源代码级的调试。

l VS2005中打开Pipeline component项目

l Pipeline component项目输出路径指向<biztalk install directory>/Pipeline Components目录。

l VS2005debug菜单中选“Attach to Process”,如下图。在进程中选“BTSNTSvc.exe”,这是biztalk的服务进程,然后点击Attach按钮,把进程附加到VS2005

figure1. 附加进程

l Pipeline component代码中需要调试的地方设置断点。

l 在相应的输入位置提供输入消息,以便消息进入使用了定制Pipeline component的管道,在运行到设置了断点的代码处,进程暂停,即可进行断点调试。

2、 利用pipeline.exe调试未部署的Pipeline component

如果只定制了Pipeline component,并使用这个Pipeline component设计了一个管道,即有了使用这个定制Pipeline componentbtp文件,这时就可对Pipeline component进行源代码级的调试了。

这种情况需要使用pipeline.exe工具调试Pipeline component

l VS2005中打开Pipeline component项目

l Pipeline component项目输出路径指向<biztalk install directory>/Pipeline Components目录。

l 改变Pipeline component项目的启动动作,打开Pipeline component项目的属性页。选左边debug标签,在start action下选择“Start external program”,然后点击“…”按钮,在路径<biztalk Installation Folder>/SDK/Utilities/Pipelinetools中选择 Pipeline.exe,表示使用pipeline来启动这个Pipeline component项目。在Start Options输入相应的命令行参数。参数设置:
首先指定btp文件,即在管道中使用了这个Pipeline component的管道文件
其次指定输入文件
最后指定输出文件
一个参数看上去像这样:
C:/Samples/Unzipdisassembler/PipelineTest/UnzipTest.btp -d C:/Samples/Unzipdisassembler/test.zip -t -m C:/Samples/Unzipdisassembler/out/Part_%MessagePartID%.out

l Pipeline component代码中需要调试的地方设置断点。

l 把输入文件放入到参数中指定的位置。

l F5开始运行

三、 定制disassembler Pipeline component的注意事项

1、 不要在代码关闭输入stream

输入消息的stream不仅在Pipeline component,别的组件功能可能也需要使用这个stream,比如HAT跟踪组件也要使用消息stream来跟踪消息。如果在定制Pipeline component代码关闭stream,将会影响到HAT对消息的跟踪。

2、 代码中保证生成stream的当前位置放置在stream的起点

使用类似下面的代码stream的当前位置设置到stream的起点:

myDataStream.Seek(0,SeekOrigin.Begin);

因为如果不把stream的当前位置设置回起点,还处于stream的终点处,这个stream进入到下一个stage的组件中,组件代码直接读取stream,会读不出内容,导致意想不到的结果。

3、 在定制管道组件的任何字符串变量中都不要包含换行符

在使用biztalk 2006时,在在定制管道组件的任何字符串变量中都不要包含换行符,比如/n,否则,在编译这个组件是会得到一个newline in constant错误

4、 使用命令行排除非组件代码错误

有时由于一些设置问题或者管道文件btp被手工修改又被改错了,这些问题不是定制管道本身的问题,会导致管道组件不被执行,表现现象一般是在VS2005中使用pipeline.exe进行源代码调式时,运行后始终运行不到断点就推出了,也没有任何提示

这时可以进入命令行模式,直接运行pipeline.exe,命令后面跟上在VS2005环境中设置的pipeline.exe的调试参数,执行。如果是调试参数或者btp文件本身的设置问题,pipeline.exe命令会有出错提示,下面是两个比较常见的问题:

4.1. pipeline.exe调试时路径参数如有空格需要引号

使用pipeline.exe调试时参数管道文件、输入、输出文件路径如有空格,比如btp文件所在的路径是这样:C:/Unzipdisassembler/PipelineTest project/UnzipTest.btp

路径中包含有空格字符,就必须把路径用引号把路径包含起来,不然pipeline.exe会找不到文件提示以下错误

Source: Pipeline

Message: Pipeline file name is already specified

4.2. 管道btp文件设置错误

如果管道文件中的配置有错误,比如Stage标签的结束标签被改成了小写的stage,就会被提示以下错误

Source: System.Xml

Message: 37 上的开始标记Stage”与结束标记stage”不匹配。

39,位置 7

相关文章

迭代器模式(Iterator)迭代器模式(Iterator)[Cursor]意图...
高性能IO模型浅析服务器端编程经常需要构造高性能的IO模型,...
策略模式(Strategy)策略模式(Strategy)[Policy]意图:定...
访问者模式(Visitor)访问者模式(Visitor)意图:表示一个...
命令模式(Command)命令模式(Command)[Action/Transactio...
生成器模式(Builder)生成器模式(Builder)意图:将一个对...