none
Need help in making output streams for custom disassembler component RRS feed

  • Question

  • I made a disassemble component which processes flat files and archives them.

    And the last part of code which is  

     public IBaseMessage GetNext(IPipelineContext pContext)
            {
                    if (streams.Count > 0)
                {
                    IBaseMessage outMsg = null;
                    byte[] byteArray = Encoding.ASCII.GetBytes(streams.Last.ToString());
                    Stream stream =  new MemoryStream( byteArray );
                    outMsg.BodyPart.Data = stream;
                    streams.RemoveLast();
                    return outMsg;
                }
                else
                    return null;
            }
    

    This is supposed to send IBaseMessages which makes the output files later.  As u can see i stored all the output messages that should be sent as strings and now i need to convert them to stream and put it insode IbaseMessage and send it.

    But it is giving me the following error:Reason: Object reference not set to an instance of an object.

    Anyhelp is very appreciated.

    Thank You,

     

    Tuesday, September 13, 2011 9:54 PM

Answers

All replies

  • I wrote a disassembler pipeline component for flatfiles.

    It takes the files and splits the files as needed and i archive them in a location.

    Now the last part is send these output as a stream in the following function:

    public IBaseMessage GetNext(IPipelineContext pContext)
    { 
                if (streams.Count > 0)
                {
                     IBaseMessage outMsg = null;
                    byte[] byteArray = Encoding.ASCII.GetBytes(streams.Last.ToString());
                    Stream stream =  new MemoryStream( byteArray );
                    outMsg.BodyPart.Data = stream;
                    streams.RemoveLast();
                    return outMsg;
                }
                else
                    return null;
    }


    As you can see i have all the output streams that should be sent stored as string in a list.

    I have been trying to convert this into a stream and send it as output but nothing seems to work.

    It gives the following error:  "Object reference not set to an instance of an object. "

     

    Thanks in advance.

    Any help is really appreciated.

    Tuesday, September 13, 2011 9:41 PM
  • You need to create message using the message factory in the Disassemble function as done in this post. Following function in this post is using it.
    public IBaseMessage CreateMessage(IPipelineContext pc, IBaseMessageContext sourceContext, IBaseMessagePart part)
    {
        IBaseMessage msg = pc.GetMessageFactory().CreateMessage();
        msg.AddPart("Body", part, true);
    
    
        // comment out the following line to preserve the original message
        msg.BodyPart.Data = new MemoryStream(ASCIIEncoding.ASCII.GetBytes("blah blah blah"));
        msg.Context = sourceContext;
        msg.Context.Promote("MessageType", systemPropertiesNamespace, messageType);
        return msg;
    }


    Don't forget to mark the post as answer or vote as helpful if it does, Regards -Rohit Sharma (http://rohitbiztalk.blogspot.com)
    • Marked as answer by raghu3119 Wednesday, September 14, 2011 6:29 PM
    • Unmarked as answer by raghu3119 Wednesday, September 14, 2011 6:34 PM
    Wednesday, September 14, 2011 3:48 AM
  • Look at this msdn article on Extending Flat File Disassembler pipeline component. Also look at this handling incoming data streams in pipeline components.
    Cheers,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    Blog: http://dpsbali-biztalkweblog.blogspot.com
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.
    Wednesday, September 14, 2011 9:19 AM
  • In all of the pipelines I have ever developed, I have always had to set the position of the stream back to 0, otherwise the stream is at the end, which means there is 'no data.'

    Let us know how you fare on this problem.


    Eric Stott [http://blog.biztalk-info.com] - Mark as Answer if this reply does.
    Friday, September 16, 2011 8:33 PM