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. JavaScript 再谈闭包

    之前有整理过一版关于闭包的概念,但感觉思路不是很清晰,是临时想起一些例子来讲的,今天再次来讲一下闭包. 闭包: 函数嵌套函数,内部函数可以引用外部函数的参数和变量 function aaa(a){ v ...

  2. JavaScript的作用域

    JavaScript的作用域主要是指函数的作用域,在进行结果判断的时候十分重要,如果不清楚作用域,便很有可能导致拿不到预期的结果,也就无法顺利的进行程序的编写,在经历了一系列的学习和了解之后,对相关知 ...

  3. Redis持久化方案

    Redis可以实现数据的持久化存储,即将数据保存到磁盘上. Redis的持久化存储提供两种方式:RDB与AOF.RDB是默认配置.AOF需要手动开启. 默认redis是会以快照的形式将数据持久化到磁盘 ...

  4. Lintcode247 Segment Tree Query II solution 题解

    [题目描述] For an array, we can build a Segment Tree for it, each node stores an extra attribute count t ...

  5. 将["a"=1,"b"=2] 转为对象

    var obj = {}; var arr = ["a=1","b=2","c=3"]; for (var x in arr){ var s ...

  6. jQuery对于动态生成的元素绑定无效的问题~~

    问题:很多时候发现,对动态生成的元素绑定click事件是无效的- 原因:直接绑定到动态生成的元素是无效的,是因为Jquery扫描文档找出所有的$(‘’)元素,并把函数绑定到每个元素的click事件上, ...

  7. ACM搜索问题盘点

    深度搜索:棋盘问题,详见http://poj.org/problem?id=1321 //#include<bits/stdc++.h> #include<cstdio> #i ...

  8. 可视化:svg相关基础

    01.svg的嵌入.html <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...

  9. 在java或 js中的日期时间转换问题

    1.在js中需要求的当前日期的周一和周日 var now = new Date(); // 当前日期时间对象 var date = now.getDate(); // 当前是几号:当前日期在一个月中的 ...

  10. 0x00-Kali Linux 系列入门篇

    Kali Linux介绍篇 Kali Linux 官网:https://www.kali.org/ Kali Linux 前身是著名渗透测试系统BackTrack ,是一个基于 Debian 的 Li ...