zoukankan      html  css  js  c++  java
  • 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 + " 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文件

    编辑输入参数

  • 相关阅读:
    对指定文件生成数字摘要的MD5工具类
    shell脚本学习积累笔记(第一篇)
    java项目打成jar包时引用了第三方jar,此时我们该如何解决呢
    分享关于学习new BufferedWriter()方法时常遇到的一个无厘头的问题
    WebService学习整理(一)——客户端三种调用方式整理
    TZOJ 挑战题库随机训练02
    TZOJ 挑战题库随机训练01
    TZOJ 2943 Running Median(动态中位数)
    TZOJ 3927 Circular Sequence(环形最大子段和)
    TZOJ 3698 GCD depth(数学)
  • 原文地址:https://www.cnblogs.com/neozhu/p/7877802.html
Copyright © 2011-2022 走看看