06-09-06 12:18 AM
Hi
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;
}
public static byte[] StrToByteArray(string str)
{
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}
[ Post a follow-up to this message ]
|