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文件
編輯輸入參數
?
轉載于:https://www.cnblogs.com/neozhu/p/7877802.html
總結
以上是生活随笔為你收集整理的AssemblyExecuteAdapter的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HTML之Position用法
- 下一篇: 从Powershell 入侵脚本学到的如