You can grab a handle to an instance of a subtype of this interface from within the Dissassemble method using the IPipelineContext.GetMessageFactory().
An important thing to note is that in order to preserve the message context you must grab this from the original message and poke it into the new instances created by the factory. The following code illustrates it.
public void Disassemble(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
{
IBaseMessageContext sourceContext = inmsg.Context; IBaseMessagePart part = inmsg.BodyPart;
// queue four messages to be processed in the GetNext() method.
// _msgs is a simple Queue
_msgs.Enqueue(CreateMessage(pc, sourceContext,part));
_msgs.Enqueue(CreateMessage(pc, sourceContext,part));
_msgs.Enqueue(CreateMessage(pc, sourceContext,part));
_msgs.Enqueue(CreateMessage(pc, sourceContext,part));
}
private string messageType = @"http://www.myschema.com/schemas/myschemamessage/MySchema";
private string systemPropertiesNamespace = @"http://schemas.microsoft.com/BizTalk/2003/system-properties";
public IBaseMessage CreateMessage(IPipelineContext pc, IBaseMessageContext sourceContext, IBaseMessagePart part)
{
IBaseMessage msg = pc.GetMessageFactory().CreateMessage();
msg.AddPart("Body", part, true);
// comment out the following line to preserve the original message
msg.BodyPart.Data = new MemoryStream(ASCIIEncoding.ASCII.GetBytes("blah blah blah"));
msg.Context = sourceContext; msg.Context.Promote("MessageType", systemPropertiesNamespace, messageType);
return msg;
}
By James Mann
How can I publish the message created here into BizTalk server?
ReplyDelete