locked
Programatically sending an xml for custom receive pipeline RRS feed

  • Question

  • Hi All,

    I have created a custom pipeline for updating an xml as given in this link.

    http://blog.pearltechnology.com/creating-a-custom-pipeline-component-for-biztalk-2010-server-part-1/

     And the above custom pipeline works well when i input a xml file from specified location. But my requirement is to pragmatically send an XML as Message. For that i have used this code in the client application

    var xml = @"<?xml version='1.0' encoding='ISO-8859-1' ?><People><FirstName>your_First_Name</FirstName><LastName>your_Last_Name</LastName></People>";
    
     XmlReader xmlReader = XmlReader.Create(new MemoryStream(Encoding.ASCII.GetBytes(xml)));
    
    Message inMessage = Message.CreateMessage(MessageVersion.None, "newaction", xmlReader);
    
    NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
    
    EndpointAddress endpointAddress = new EndpointAddress(addressURI);
    
    ChannelFactory<IReceiveMessage> factory = new ChannelFactory<IReceiveMessage>(binding, endpointAddress);
    
    IReceiveMessage channel = factory.CreateChannel();
    
    Message outMessage = channel.ReceiveTwoWay(inMessage);
    
    string bodyContent = outMessage.ToString();
    

    But when i pass through it throws the below issue in biztalk receive port :

    "Unexpected token at encoding"

    Kindly provide your help.

    Thanks & Regards,

    Dani

    Tuesday, April 23, 2013 4:14 PM

Answers

  • Hi Dani,

    Why do you need the encoding to be " ISO-8859-1", can you change it to "UTF-8".

    And also try to avoid XMLDocuument in the custom pipeline. You will have performacen issues.  The amount of space required by an instance of the XmlDocument class to load and create an in-memory representation of a XML document is up to 10 times the actual message size.

    Try to use XmlTextReader along with VirtualStream/ seekable streams:

    http://msdn.microsoft.com/en-gb/library/ee377071(v=bts.10).aspx


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.


    Tuesday, April 23, 2013 4:27 PM

All replies

  • Hi Dani,

    Why do you need the encoding to be " ISO-8859-1", can you change it to "UTF-8".

    And also try to avoid XMLDocuument in the custom pipeline. You will have performacen issues.  The amount of space required by an instance of the XmlDocument class to load and create an in-memory representation of a XML document is up to 10 times the actual message size.

    Try to use XmlTextReader along with VirtualStream/ seekable streams:

    http://msdn.microsoft.com/en-gb/library/ee377071(v=bts.10).aspx


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.


    Tuesday, April 23, 2013 4:27 PM
  • There's two things going on here, a Pipeline Component and what appears to be a WCF client stack.

    Where exactly is the error appearing, in the client or server.  You may have an unintended BOM in the string, which the ASCII encoder may not like.  I usually use a StringWriter though.

    Could you describe your scenario a little more?  These two pieces, the Pipeline Component and the WCF stack are pretty much unrelated.

    Tuesday, April 23, 2013 5:55 PM
    Moderator