2016-01-20 19 views
1

我試圖使用下面的代碼將.net類庫中的虛擬錯誤消息發送到ESB管理門戶。已經使用了由ESB ExceptionHandling Service提供的WCF服務並創建了它的客戶端。發送ESB工具包的FaultMessage對象以在ESB門戶上顯示錯誤消息

   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,版本= 2.1.0.0,文化=中立,公鑰= 31bf3856ad364e35「源:」ESB BAM Tracker「發送端口:」ALL.Exceptions「URI:」SQL://(local)/ EsbExceptionDb /「原因:發生意外的文件結尾。以下元素未關閉:ns0:FaultMessage。第20行,位置12

+0

這是使用BizTalk嗎?如果是這樣,您可能需要添加biztalk標記以及相應的biztalk版本標記 – Dijkgraaf

+0

也許您需要在從您的測試客戶端發送之前在faultMsg上使用XmlSerializer?我已經在下面添加了一個關於如何從BizTalk業務流程發送錯誤消息的答案,這也可能會提供一些線索 – Dijkgraaf

回答

0

如果發送從BizTalk業務流程你的異常消息可以做在創建類型Microsoft.Practices.ESB.ExceptionHandling.Schemas.Faults的faultMsg一個構建體形狀以下。 FaultMessage

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. 01自動填充
  3. 您不必使用Web服務。你只需要在BizTalk項目下列
    Microsoft.Practices.ESB.Exception.Management
    Microsoft.Practices.ESB.ExceptionHandling
    Microsoft.Practices.ESB.ExceptionHandling.Schemas.Faults參考