AssemblyExecuteAdapter
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;
}
配置
配置发送端口

配置参数

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的更多相关文章
随机推荐
- react-todoMVC脚手架
webpack.config.js var path = require('path'); // node中的 路径解析的模块 const HtmlWebpackPlugin =require('ht ...
- wpf 研究之道 winform or wpf,u choose who?
很久以前,我们用winform做过一个五子棋的程序,当时用winform的画图,先画出棋盘...后来项目的研究阶段,偶尔用winform做个小工具.闲暇之余,看到介绍wpf的资料,只知道它采用了xam ...
- MinGW安装和使用
P.S.安装MinGW主要是code blocks 编译出现了这个问题: ERROR: You need to specify a debugger program in the debuggers' ...
- 【Unity与23种设计模式】备忘录模式(Memento)
GoF中定义: "在不违反封装的原则下,获取一个对象的内部状态并保留在外部,让对象可以在日后恢复到原先保留时的状态." 对于一些需要存储的数据,比如历史最高分 当与得分减分系统写入 ...
- map/vector erase
问题核心:erase之后迭代器是否失效 vector调用erase之后,该迭代器之后的迭代器都失效: map调用erase之后,其他迭代器并不会失效. vector<int> vecDat ...
- Selenium和Firefox兼容问题
运行时遇到错误: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on p ...
- 关于Spring注解@Async引发其他注解失效
概述 在前面一篇文章中,介绍,在一个Bean中注入自己,如果有@Async和@Transaction,如果使用@Autowire注入自身,会报循环依赖,如果使用BeanFactoryAware注入自己 ...
- 百度API地图的标注不居中显示,而显示在左上角
前言:今天弄个百度地图,弄了半天就是不居中,之前使用一直没有遇到这个问题.所以就一直在找原因. 百度地图对地图所在的div做了显示隐藏之类操作,标注就不再居中显示,而显示在左上角. 查了很久,有人提出 ...
- JVM学习六:JVM之类加载器之双亲委派机制
前面我们知道类加载有系统自带的3种加载器,也有自定义的加载器,那么这些加载器之间的关系是什么,已经在加载类的时候,谁去加载呢?这节,我们将进行讲解. 一.双亲委派机制 JVM的ClassLoader采 ...
- [poj1185]炮兵阵地_状压dp
炮兵阵地 poj-1185 题目大意:给出n列m行,在其中添加炮兵,问最多能加的炮兵数. 注释:n<=100,m<=10.然后只能在平原的地方建立炮兵. 想法:第2到状压dp,++.这题显 ...