Skip to content

Latest commit

 

History

History
36 lines (32 loc) · 1.49 KB

subscribing-to-and-extracting-messages.md

File metadata and controls

36 lines (32 loc) · 1.49 KB
description title ms.custom ms.date ms.service ms.reviewer ms.suite ms.topic
Learn more about: Subscribing to and Extracting Messages
Subscribing to and Extracting Messages
06/08/2017
biztalk-server
article

Subscribing to and Extracting Messages

Orchestration can contain code to subscribe to and extract messages from an ESB fault message. For example, the following code uses the GetMessage and GetException methods to extract two strongly typed messages and the System.Exception object from an ESB fault message.

// Retrieve two messages from the fault message.  
requestMsg = Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.GetMessage(  
                                    faultMsg, "ApprovedRequest");  
deniedMsg = Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.GetMessage(  
                                    faultMsg, "DeniedRequest");  
  
// Retrieve the System.Exception object.  
newExc = Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.GetException(  
                                    faultMsg);  

To extract type-less messages, the following code uses the GetMessages method to extract all the messages and then iterate through them.

Microsoft.Practices.ESB.ExceptionHandling.MessageCollection msgs;  
msgs = Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.GetMessages(faultMsg);  
System.Xml.XmlDocument tmpMsg;  
while (msgs.MoveNext())  
{  
  tmpMsg = msgs.Current;  
}