1

我正在尝试使用以下代码将 .net 类库中的虚拟故障消息发送到 ESB 管理门户。已经消费了 ESB ExceptionHandling Service 提供的 WCF 服务并创建了它的客户端。

                ExceptionHandlingClient clientESB = new ExceptionHandlingClient();
                FaultMessage faultMsg = new FaultMessage();

                faultMsg.Header = new FaultMessageHeader();
                faultMsg.Header.Application = "Exception Handling Service Test";
                faultMsg.Header.Description = "Fault Message Header";
                faultMsg.Header.ErrorType = "Error Type";
                faultMsg.Header.FaultSeverity = 1;
                faultMsg.Header.FaultCode = "Fault Code";
                faultMsg.Header.FailureCategory = "Failure Category";
                faultMsg.Header.FaultDescription = "Fault Description";
                faultMsg.Header.FaultGenerator = "Fault Generator";
                faultMsg.Header.Scope = "Fault Message Scopte";
                faultMsg.Header.ServiceInstanceID = System.Guid.NewGuid().ToString();
                faultMsg.Header.ServiceName = "Exception Service";
                faultMsg.Header.MachineName = System.Environment.MachineName;
                faultMsg.Header.DateTime = System.DateTime.Now.ToString();
                faultMsg.Header.ControlBit = "1";
                faultMsg.Header.MessageID = System.Guid.NewGuid().ToString();
                faultMsg.Header.ActivityIdentity = "Activity Identity ";
                faultMsg.Header.NACK = false;
                 //Use the 'client' variable to call operations on the service.
                clientESB.Open();
                clientESB.SubmitFault(faultMsg);

当上面的代码执行时,它成功地设置了 FaultMessage 对象的属性。此请求在到达 ALL.Exceptions 发送端口时失败,并显示以下错误消息。

执行发送管道失败:“Microsoft.Practices.ESB.ExceptionHandling.Pipelines.ESBFaultProcessor,Microsoft.Practices.ESB.ExceptionHandling.Pipelines,Version=2.1.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”来源:“ESB BAM Tracker" 发送端口:"ALL.Exceptions" URI:"SQL://(local)/EsbExceptionDb/" 原因:文件意外结束。以下元素未关闭:ns0:FaultMessage。第 20 行,第 12 位。

4

1 回答 1

0

如果您从 BizTalk 业务流程发送异常消息,您可以在创建 Microsoft.Practices.ESB.ExceptionHandling.Schemas.Faults.FaultMessage 类型的 faultMsg 的构造形状中执行以下操作

faultMsg = Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.CreateFaultMessage();
faultMsg.FailureCategory = "Failure Category";
faultMsg.FaultCode = "Fault Code";
faultMsg.FaultSeverity = Microsoft.Practices.ESB.ExceptionHandling.FaultSeverity.Error;
faultMsg.FaultDescription = "Fault Description";
faultMsg.Scope = "Fault Message Scope";

笔记:

  1. 您不必设置应用程序或其他设置,因为它们会在 BizTalk 中自动填充
  2. 您不必使用 Web 服务。您只需要在 BizTalk 项目中引用以下
    Microsoft.Practices.ESB.Exception.Management
    Microsoft.Practices.ESB.ExceptionHandling
    Microsoft.Practices.ESB.ExceptionHandling.Schemas.Faults
于 2016-07-20T04:25:40.383 回答