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的更多相关文章

随机推荐

  1. Android TV 电视调试和遥控器事件监听

    Android TV 真机调试 要进行Android TV开发免不了要进行真机调试. 1.确定电视盒子和开发机器在同一局域网中 2.打开电视盒子的adb允许调试开关 3.进入adb所在文件夹进行adb ...

  2. 学习ASP.NET Core Razor 编程系列一

    一. 概述 .NET Core 1.0发布的时候就想进行学习的,不过根据微软的以往的发布规律1.0版可以认为是大众测试版,2.0才算稳定.现在2.1都已经发布了预览版,之前对其"不稳定&qu ...

  3. Redis 安装简介

    Redis 是一个高性能的key-value数据库. redis的出现,很大程度补偿了memcached这类key/value存储的不足,在部 分场合可以对关系数据库起到很好的补充作用.它提供了Jav ...

  4. Qt中QComboBox中自定义界面使用stylesheet实现下拉按钮独立效果

    使用QSS自定义控件界面时,QT中控件QCombobox含有两个子控件drop-down和down-arrow.一般而言,当改变QCombox时,很多效果都会出来,但是,针对下拉按钮和下拉图标的自定义 ...

  5. windows下远程访问Redis,windows Redis绑定ip无效,Redis设置密码无效,Windows Redis 配置不生效,Windows Redis requirepass不生效,windows下远程访问redis的配置

    转载:http://fanshuyao.iteye.com/blog/2384074 一.Redis下载地址: https://github.com/MicrosoftArchive/redis/re ...

  6. 原生js移动端滑动事件

    移动端触屏滑动的效果其实就是图片轮播,在PC的页面上很好实现,绑定click和mouseover等事件来完成.但是在移动设备上,要实现这种轮播的效果,就需要用到核心的touch事件.处理touch事件 ...

  7. Asp.Net MVC 文件管理Demo(文件展示,上传,下载,压缩,文件重命名等)

    之前 ,有想做一个文件管理页面. 参考了 许多资料,终于完成了一个基于Asp.net MVC 的文件管理Demo.界面如下.   一,实现功能及相关技术 文件管理Demo基于Asp.NET MVC , ...

  8. svn从Windows服务器上迁移到Linux上

    svn从Windows服务器迁移到Linux服务器    author:headsen chen   2017-10-16  16:50:32  个人原创,转载请注明.否则依法追究法律责任       ...

  9. extract-text-webpack-plugin---webpack插件

    var ExtractTextPlugin=require('extract-text-webpack-plugin');//build使用 { test:/\.css$/, use:ExtractT ...

  10. poj-1207 THE 3n+1 problem

    Description Problems in Computer Science are often classified as belonging to a certain class of pro ...