none
Biztalk custom send pipeline Using memory stream RRS feed

  • Question

  • Hi friends,

    I developing the custom send pipeline,I am calling the custom helper class.The helper class I am using the Memory stream.

    The helper class method is looks like:

    public MemoryStream UpdateProcess(MemoryStream ms)

    In the pipeline i need to call this method 

     public IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)
            {
                
                        //To get Incoming message
                System.IO.Stream originalStream = inmsg.BodyPart.GetOriginalDataStream();
                //Working with XDocument
                XDocument xDoc;
                using (XmlReader reader = XmlReader.Create(originalStream))
                {
                    reader.MoveToContent();
                    xDoc = XDocument.Load(reader);
                }
                
                // Returning stream
                byte[] output = System.Text.Encoding.ASCII.GetBytes(xDoc.ToString());
                MemoryStream memoryStream = new MemoryStream();
                memoryStream.Write(output, 0, output.Length);
                ProcessHelper mf = new ProcessHelper();
                mf.UpdateProcess(memoryStream);

                memoryStream.Position = 0;
                inmsg.BodyPart.Data = memoryStream;
                return inmsg;


                                  
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (parms != null)
                        parms.Clear();
                }

                return inmsg;
            }

    Can you can any one let me know i am doing correct logic in pipeline component.

    Thanks

    hk


    hk

    Wednesday, March 5, 2014 1:35 AM

Answers

  • Realistically, we can say for sure if it's right since we don't know the implementation of the helper.

    However, since it looks like the helper expects a MemoryStream with Xml content, you can probably just copy the data from the original stream to the local MemoryStream.  Passing it through an XmlDocument might be unnecessary.

    Also, unless you are absolutely sure the source document is ASCII, you shouldn't use ASCII encoding since you can loose meaningful character data.

    • Marked as answer by Pengzhen Song Wednesday, March 12, 2014 9:28 AM
    Wednesday, March 5, 2014 12:55 PM

All replies

  • Realistically, we can say for sure if it's right since we don't know the implementation of the helper.

    However, since it looks like the helper expects a MemoryStream with Xml content, you can probably just copy the data from the original stream to the local MemoryStream.  Passing it through an XmlDocument might be unnecessary.

    Also, unless you are absolutely sure the source document is ASCII, you shouldn't use ASCII encoding since you can loose meaningful character data.

    • Marked as answer by Pengzhen Song Wednesday, March 12, 2014 9:28 AM
    Wednesday, March 5, 2014 12:55 PM
  • While working on custom pipeline, we should always try not to break streaming functionality of pipeline and thus I would avoid using XML objects.

    Also, you can debug to see if you getting proper output at run time at different stages.


    Regards, Ajeet Kumar MCTS Biztalk Server

    Wednesday, March 5, 2014 2:18 PM