Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Custom Pipeline memory stream not hitting map in same port
- This topic has 4 replies, 1 voice, and was last updated 9 years, 10 months ago by
community-content.
-
AuthorPosts
-
-
July 13, 2008 at 6:13 PM #20133
I have a custom receive pipeline that reads an Excel file and converts it to XML. It works fine unless there is a map in the same port, then the map ignores the memory stream from the pipeline.
The relevant code follows:
public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pContext, Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg)
{
. . .
// Save the final XML Document (xmlLeadDoc) to the Stream
Stream strm = new MemoryStream();
xmlLeadDoc.Save(strm);
strm.Seek(0,
SeekOrigin.Begin);
bodyPart.Data = strm;
pContext.ResourceTracker.AddResource(strm);
}
return pInMsg;
}What can I do to get the map to recognize the memory stream from the pipeline? I think that the message context for this stream needs the schema message type added, but have no idea how to accomplish this. Everything I have read indicates that the context of this stream is read-only.
However, before going down that path, I’d like to know that this assumption is the correct one. Does the stream not have a message type? Is this the problem, or should I be looking for something else?
Thanks,
-
July 13, 2008 at 6:51 PM #20134
Did you add an XML disassembler component to your pipeline? If not then the message type will not be applied and the map will not run.
-
July 13, 2008 at 7:10 PM #20135
The receive port will look at the BTS.MessageType property in the message context and see if any of the maps on the port have an input message type that matches. You can have mulitple maps defined that each map a different input message.
If the BTS.MessageType property does not match any of the configured maps then the message is published to the messagebox as is.
Typically the BTS.MessageType is set by the Disassembler, the Xml Disassembler will dynamically match the input Xml with the appropriate schema.
What stage does you custom component sit? Is it before or after the Disassemble stage? If it is before then you can add the Xml Disassembler component to your piprline. If it is after then you will need to promote the BTS.MessageType property within your component. The message context is not read only
pInMsg.Context.Promote(“MessageType”, “http://schemas.microsoft.com/BizTalk/2003/system-properties”, message_targetnamespace + “#” + message_rootElementName);
-
July 14, 2008 at 2:17 AM #20136
Following on from Greg’s comments, you should also get into the habbit of copying across all of the Context Properties that were set by the adapter – I came unstuck here too: http://www.modhul.com/2007/03/08/custom-disassembler-component-remember-the-context-properties/
Nick.
-
-
July 16, 2008 at 12:31 PM #20176
Thanks to the answers… each help a great deal. What I ended up with was very simple. The component is in the Decode Stage.
// Save the final XML Document (xmlLeadDoc) to the Stream
Stream strm = new MemoryStream();
xmlLeadDoc.Save(strm);
strm.Seek(0, SeekOrigin.Begin);
bodyPart.Data = strm;
// Promote the MessageType property to ensure subscriptions by orch’s and maps can see
string systemPropertiesNamespace = “http://schemas.microsoft.com/BizTalk/2003/system-properties“;
string messageType = NameSpaceHolder + “#” + RootNodeName;
pInMsg.Context.Promote(“MessageType”, systemPropertiesNamespace, messageType);
pContext.ResourceTracker.AddResource(strm);(And did add the XML Disassembler in the Disassemble Stage) I was led astray by thinking that I needed to clone the message. Finally realized that wasn’t the case. Then the component would fail because the namespace was wrong. When debugging found that the property bag would be loaded with the right namespace (from component’s property I entered), but would do a 2nd read of the property bag and get an old, but wrong value!!! It took a while, but finally realized that when the test harness was being redeployed the pipeline at the receive location did not reset to the passthrough one and that the property it was holding was the old value.
After that the testing of the component went fine and deployed it – sheesh – a big effort to learn a very little (but very important) thing.
Thanks again to all.
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.