Re: Custom pipeline issue



That worked you are my hero. Just for interest why is the rewind necessary?

Does my code look "efficient" enough? This custom pipeline is going to be
used ni a vast majority of our biztalk projects.







"Tomas Restrepo (MVP)" <tomasr@xxxxxxxx> wrote in message
news:OivSIEziGHA.4368@xxxxxxxxxxxxxxxxxxxxxxx

I'm attempting to wrote a custom pipeline, in summary all I'm trying to
do is a search & replace, this is to handle creation of an XML message
where most of XML elements are within a CDATA (don't ask why - not my
decision!)

Anyway, the code compiles and doesn't crash when I use with biztalk (or
pipeline.exe), it creates an empty file. The debug code at the end
returns 83 which is the length of the file I expect, however the file
which is created is blank .

Any hints or better ways to do this?

Thanks


public Microsoft.BizTalk.Message.Interop.IBaseMessage
Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pc,
Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
{

StreamReader ms = new StreamReader(inmsg.BodyPart.Data);
MemoryStream mms = new MemoryStream();
string content = string.Empty;

content = ms.ReadToEnd();
content = content.Replace("<cdatasection>", "<![CDATA[");
content = content.Replace("</cdatasection>", " ]]>");

byte[] imgarray = StrToByteArray(content);
mms.Write(imgarray,0,imgarray.Length);

Console.WriteLine(mms.Length);
Console.WriteLine(content);
Console.WriteLine("HELLO");
Console.WriteLine(imgarray.Length);
inmsg.BodyPart.Data = mms;
Console.WriteLine("LENGTH OF INMSG = ");
Console.WriteLine(inmsg.BodyPart.Data.Length);

return inmsg;

}

Rewind the stream at the end just before assigning it as the body part
data:

mms.Position = 0;
inmsg.BodyPart.Data = mms;


--
Tomas Restrepo
tomasr@xxxxxxxx
http://www.winterdom.com/



.



Relevant Pages

  • Re: Custom pipeline issue
    ... I'm attempting to wrote a custom pipeline, in summary all I'm trying to ... Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg) ... StreamReader ms = new StreamReader; ... MemoryStream mms = new MemoryStream; ...
    (microsoft.public.biztalk.general)
  • Re: Custom pipeline issue
    ... most of XML elements are within a CDATA ... Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg) ... StreamReader ms = new StreamReader; ... MemoryStream mms = new MemoryStream; ...
    (microsoft.public.biztalk.general)