Re: Stream handling in custom pipeline component

From: Peter Timkˇ (ptimko_at_online.com)
Date: 06/15/04


Date: Tue, 15 Jun 2021 08:23:16 +0200

Hi John,

Thanks for your help,

That code part is the following:

public Microsoft.BizTalk.Message.Interop.IBaseMessage
Execute(IPipelineContext pContext,
Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg)
{
 if(_ShowMessageStream)
 {
  Stream s = pInMsg.BodyPart.Data;
  StreamReader sr = new StreamReader(s);
  MessageBox.Show("Message Body:\r\n" + sr.ReadToEnd(), "Pipeline Tracer -
Message Data - " + pContext.PipelineName, MessageBoxButtons.OK,
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1,
MessageBoxOptions.DefaultDesktopOnly);
  s.Close();
 }
 return pInMsg;
}

Regards:

Peter

"John Plummer [MSFT]" <jplummernospam@nospamms.com> wrote in message
news:eUfZGGkUEHA.2508@TK2MSFTNGP12.phx.gbl...
> It might be easier if you attach a code sample
>
> are you setting the stream to Pos=0;
>
>
> "Peter Timkˇ" <ptimko@online.com> wrote in message
> news:%232kB7GfUEHA.2844@TK2MSFTNGP12.phx.gbl...
> > Dear All,
> >
> > I've created a simple general pipeline which purpose would be to trace
out
> > the message and the message context. This component is allowed to be in
> the
> > decode, validate, resolve party, encode stages.
> >
> > I'm using the Stream s = pInMsg.BodyPart.Data; statement to get the data
> > stream (according to the documentation the data property clones the
> oroginal
> > stream). After it I use a StreamReader class and the ReadToEnd method to
> > read from the stream. When it is finished I close the stream (i think it
> is
> > ok because it is not the original stream).
> >
> > If this pipeline component is in the decode stage it works just fine.
But
> if
> > it is in the Validate stage it can read out the message data from the
> > stream, but BizTalk doesn't get message, and throw an error to the
> eventlog.
> > If it is in the encode stage in the send side the components can read
the
> > message but the output message is empty.
> >
> > The last statement in my IComponent.Execute method is return pInMsg to
> > always return the original message and context.
> >
> > What am I doing wrong?
> >
> > Regards:
> >
> > Peter
> >
> >
>
>