Is it possible to convert Microsoft.BizTalk.Operations.BizTalkMessage instance to Microsoft.XLANGs.BaseTypes.XLANGMessage instance (without losing context from BizTalkMessage)?
The reason is that I want to retrieve all constructed orchestration message instances and then add these messages to ESB Toolkit method:
private List<BizTalkMessage> GetOrchestrationMessages()
{
List<BizTalkMessage> messages = new List<BizTalkMessage>();
MessageBoxServiceInstance serviceInstance = GetServiceInstance();
foreach (object item in serviceInstance.Messages)
{
BizTalkMessage bizTalkMessage = (BizTalkMessage)item;
messages.Add(bizTalkMessage);
}
return messages;
}
public void HelperMethod(XLANGMessage faultMessage)
{
foreach(BizTalkMessage biztalkMessage in GetOrchestrationMessages)
{
XLANGMessage xlangMessage = ConvertToXLANGMessage(biztalkMessage);
Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.AddMessage(faultMessage, xlangMessage);
}
}
So, the main question is how to implement ConvertToXLANGMessage
method?
Thank you!
There are no direct casts among any of the BizTalk Message Types, XLANGMessage, IBaseMessage, WMI, etc.
Can you do it? Sure, but you'd essentially be recreating the message manually.
Also, I'm pretty sure your code will only get the Messages routed to an Orchestration, not any of the internal/persisted instances.
I have to ask, why are you doing this? It would be better to just handle you Fault message inside the Orchestration using regular exception handling techniques.