Error calling a Receive Pipeline in an Orchestration.
Hi,
I have a custom pipeline component in a Receive Pipeline in which I apply an xsl transformation to the original xml. If I call this pipeline from within an orchestration I get an error in my costruct message shape about an Object not set to an instance of an object. However if the component is in a Send Pipeline and set on a Send Port its OK. I suspect it is the way I construct and return the message somehow.
This is how I call the Pipeline in the orchestration (from within a Message Construction Shape):
outMsgCopy = null;
objPipelinexslt = Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline(typeof( Pipelines.Woolworths.xsltTransform), outMsg );
objPipelinexslt.MoveNext();
objPipelinexslt.GetCurrent(outMsgCopy);
outMsgCopy(*) = inMsg(*);
IBaseMessage
Microsoft.BizTalk.Component.Interop.IComponent.Execute(IPipelineContext pContext,IBaseMessage pInMsg){
//return pInMsg;
IBaseMessagePart bodyPart = pInMsg.BodyPart;
Stream xmlData = bodyPart.Data;
Stream transformedMsg = TransformMessage(xmlData);
// Create a new message
IBaseMessage outputMessage = pContext.GetMessageFactory().CreateMessage();
// Copy message context
outputMessage.Context = pInMsg.Context;
// Create a new body part
IBaseMessagePart newBodyPart = pContext.GetMessageFactory().CreateMessagePart();
// Seek to the start of the stream
if (transformedMsg.CanSeek)
transformedMsg.Seek(0,SeekOrigin.Begin);
// Set the new body part's stream
newBodyPart.Data = transformedMsg;
outputMessage.AddPart("body", newBodyPart,true);
pContext.ResourceTracker.AddResource(newBodyPart);
return outputMessage;
}
privateStream TransformMessage(Stream inputMessage)
{
XslCompiledTransform transformer =newXslCompiledTransform();
byte[] outBytes = System.Text.Encoding.ASCII.GetBytes
(CustomXSLT);
MemoryStream memStream =newMemoryStream();
memStream.Write(outBytes, 0, outBytes.Length);
memStream.Position = 0;
XPathDocument xsltDoc =newXPathDocument((Stream)memStream);
MemoryStream destnStream =newMemoryStream();
transformer.Load(xsltDoc);
XPathDocument doc =newXPathDocument(inputMessage);
transformer.Transform(doc,null, destnStream);
return (Stream)destnStream;
}

