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使用JSON数据和服务器进行交互

    //点击按钮发送反馈信息给服务端,成功则进入优惠券界面 Button upload = (Button) findViewById(R.id.upload); final String finalLa ...

  2. Ansible学习总结(1)

    ---恢复内容开始--- 1. Ansible概述 ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fabric) ...

  3. MongoDB 桌面管理器MongoVUE

    MongoVUE是一个桌面GUI工具,专用于Windows平台,它有一个简洁.清爽的界面,它的基本功能是免费的.它可以以文本视图.树视图.表格视图来显示MongoDB的数据.还可以保持查询的结果供以后 ...

  4. c++中回调函数和函数指针的使用

    #include "stdafx.h" #include <iostream> //#include <string> using namespace st ...

  5. generator生成器iterator遍历器和yield

    generator方法()返回一个iterator 使用generator时永远先去调用generator()方法 for of对iterator的调用过程(babel参照) 1,_iterator. ...

  6. webpack4新特性介绍

    导语: webpack是一个JS应用打包器, 它将应用中的各个模块打成一个或者多个bundle文件.借助loaders和plugins,它可以改变.压缩和优化各种各样的文件.它的输入是不同的资源,比如 ...

  7. New UWP Community Toolkit

    概述 UWP Community Toolkit 是一个 UWP App 自定义控件.应用服务和帮助方法的集合,能够很大程度的简化和指引开发者的开发工作,相信广大 UWPer 并不陌生. 下面是截取自 ...

  8. 设计模式 --> (9)代理模式

    代理模式 为其他对象提供一种代理以控制对这个对象的访问. 主要解决的问题是:在直接访问对象时带来的问题,比如说:要访问的对象在远程的机器上.在面向对象系统中,有些对象由于某些原因(比如对象创建开销很大 ...

  9. postman 简单教程-实现简单的接口测试

    最近开始做接口测试了,因为公司电脑刚好有postman,于是就用postman来做接口测试,哈哈哈哈,...postman 功能蛮强大的,还比较好用,下面说下postman如何来测试接口 1.下载po ...

  10. Konckout第一个实例:简单数据模型绑定

    Konck是什么: http://www.aizhengli.com/knockoutjs/50/knockout.html 使用:直接引入knockout.js文件 第一个实例:实现输入框输入值改变 ...