首页 技术 正文
技术 2022年11月20日
0 收藏 744 点赞 2,206 浏览 2411 个字

BizTalk custom adapter

AssemblyExecuteAdapter

功能

更为方便的扩展BizTalk custom adapter 的交互方式,只需要实现IAssemblyExecute 接口就可以让BizTalk AssemblyExecuteAdapter 执行需要的业务逻辑。

代码

AssemblyExecuteAdapterTransmitterEndpoint.cs

通过配置需要加载的dll 文件来执行dll 内部处理逻辑

private Stream SendAssemblyExecuteAdapterRequest(IBaseMessage msg, AssemblyExecuteAdapterTransmitProperties config)

{

VirtualStream responseStream = null;

string charset = string.Empty;

IBaseMessagePart bodyPart = msg.BodyPart;

Stream btsStream;

string messageid = msg.MessageID.ToString(“D”);

if (null != bodyPart && (null != (btsStream = bodyPart.GetOriginalDataStream())))

{

try

{

Type assemblyExecuteType = Type.GetType(config.AssemblyName);

IAssemblyExecute assemblyexecute = (IAssemblyExecute)Activator.CreateInstance(assemblyExecuteType);

object inputparameters = null;

if (!string.IsNullOrEmpty(config.InputParameterXml))

{

XmlDocument inputXml = new XmlDocument();

inputXml.LoadXml(config.InputParameterXml);

inputparameters = assemblyexecute.GetInputParameter(inputXml);

}

Stream stream = assemblyexecute.ExecuteResponse(btsStream, inputparameters);

#region saveresponsemessage

string responsefilename = string.Empty;

if (config.SaveResponseMessagePath != string.Empty && config.SaveResponseMessagePath != “N”)

{

if (!Directory.Exists(config.SaveResponseMessagePath))

Directory.CreateDirectory(config.SaveResponseMessagePath);

responsefilename = Path.Combine(config.SaveResponseMessagePath, “res_” + messageid + “.txt”);

SaveFile(responsefilename, stream);

stream.Seek(0, SeekOrigin.Begin);

}

#endregion

if (config.IsTwoWay)

{

responseStream = new VirtualStream(stream);

}

}

catch(Exception e)

{

#region saveerrormessage

string errorfilename = string.Empty;

if (config.SaveErrorMessagePath != string.Empty && config.SaveErrorMessagePath != “N”) {

if (!Directory.Exists(config.SaveErrorMessagePath))

Directory.CreateDirectory(config.SaveErrorMessagePath);

errorfilename = Path.Combine(config.SaveErrorMessagePath ,messageid + “.txt”);

SaveFile(errorfilename, btsStream);

}

#endregion

string Source = “AssemblyExecuteAdapter”;

string Log = “Application”;

string Event = e.Message + “\r\n request message saved :” + errorfilename;

if (!EventLog.SourceExists(Source))

EventLog.CreateEventSource(Source, Log);

EventLog.WriteEntry(Source, Event, EventLogEntryType.Error);

throw;

}

}

return responseStream;

}

配置

配置发送端口

AssemblyExecuteAdapter

配置参数

AssemblyExecuteAdapter

Assembly qualified name:实现了IAssemblyExecute接口的dll文件

Function Name: 这个adapter的功能名称,确保唯一

Input Parameter Xml: 执行ExecuteResponse需要的参数以XML的形式提供

Save Error Message Path:保存错误报文的路径

Save Response Message Path:保存执行ExecuteResponse方法返回的结果

选择实现了IAssemblyExecute 接口的dll文件

AssemblyExecuteAdapter

编辑输入参数

AssemblyExecuteAdapter

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,990
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,504
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,348
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,133
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,765
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,843