none
Unable to read property schema fields in custom pipeline component. RRS feed

  • Question

  • I am working on Biztalk 2010, VS2010.

    Based on the promoted fields I am trying to set the outboundtransportlocation of the message.

    I have promoted few fields using quick promotion in input schema but I am unable to read these promoted fields in custom receive pipeline. Instead of value of the field, namespace is getting picked up and getting displayed.

    When I tried to implement same logic in custom send pipeline, I get "nameofthefield_string".

    Please provide some inputs to Read the property schema(promoted properties) in the pipeline?



    Friday, November 13, 2015 3:39 PM

Answers

  • To clarify, the stream reading component should be the first component in the Validate Stage.

    It should process the message immediately after the XmlDisassembler.

    • Marked as answer by Juhi Gupta Thursday, November 26, 2015 3:29 PM
    Thursday, November 26, 2015 2:19 PM

All replies

  • You are trying to read Context Properties Promoted from withing an incoming message and they are not present.  Correct?

    If so, that is the expected behavior.  Agreed, it is not ideal.

    The reason is the XmlDisassembler, which does the property promotion, is a streaming component so the Context Properties are not set until the promoted node is read through the disassembler.

    The only way around this is to force a read on the stream at least up to the value you're looking for.  Then, the property will be written with the value.

    Friday, November 13, 2015 4:02 PM
  • Hi Juhi,

    Welcome on MSDN forum.

    I would suggest you please have a look into below related thread and a article for reference,

    PropertyPromotion in Custom pipeline componen

    Accessing Promoted Properties in a Pipeline Component by Stephen Kaufman


    Thanks, If my reply is helpful please mark as answer or vote as helpful.

    Friday, November 13, 2015 4:25 PM
  • Hi Juhi,

    In addition to Boatseller advice you  You can set the Property Schema Base property attribute to MessageContextPropertyBase for each element in property schema .

    And try something like below code

    IBaseMessageContext readcontext= pinmsg.Context;
    var incontext= readcontext.Read("Name", "http://SampleSolution.PropertySchema"); 

    Thanks

    Abhishek


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply

    Friday, November 13, 2015 6:38 PM
  • Hi Juhi - in addition to everyone else's advice, if you are promoting the OutboundTransportLocation property, you may need to promote the IsDynamicSend Property as well to prevent caching of the URI like this in your pipeline component:

    inmsg.Context.Promote("IsDynamicSend", "http://schemas.microsoft.com/BizTalk/2003/system-properties", true); 

    I have written a blog article here that you may find helpful:

    https://jamescorbould.wordpress.com/2014/06/17/using-a-static-send-port-like-a-dynamic-send-port/

    Regards,

    James.


    Monday, November 16, 2015 12:33 AM
  • Hi Kamlesh,

    I did exactly as mentioned in the 2nd link you have shared. But still I am getting namespace instead of value.

    I am creating a custom receive component (validate stage) to read the schema fields, should I be creating a custom send component and then implement my logic?

    Thanks,

    Juhi Gupta


    Wednesday, November 18, 2015 10:02 AM
  • Hi John,

    I am first reading my message through Flat file dissassembler and then in second receive pipeline trying to access the schema fields. Although I tried using XMLdissassembler as well, but it is not working. I am still unable to retrieve values from the property schema.

    Wednesday, November 18, 2015 11:53 AM
  • Hi James,

    I am able to set value of Outbound URI. But i need to implement a logic by reading schema values and then set URI.

    Wednesday, November 18, 2015 11:55 AM
  • Hi Juhi,

    The problem you are facing is unfortunately an expected behavior. I had encountered this issue few months back and documented the same here in my blog-

    VERY STRANGE BEHAVIOR OF XML DISASSEMBLER- PROPERTY PROMOTION NOT HAPPENING PROPERLY

    The only way to overcome this issue is to somehow force a Read by the XmlDisassembler.

    For example in my pipeline component I had read the values using below code and forced a Read/Promote by the XmlDisassembler.

    //Reading message data using XML Document.
    
    System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
    
    xmlDoc.Load(originalStream);

    Let me know if this helps.


    Thanks,
    Prashant

    My BizTalk Blog
    -------------------------------------------------------------------------
    Please mark this post accordingly if it answers your query or is helpful.

    Thursday, November 19, 2015 4:33 PM
  • An XmlDocument is a relatively expensive way to force a Read on the stream.

    A better option wold be to copy the current Stream to a VirtualStream.

    Thursday, November 19, 2015 6:23 PM
  • Hi All,

    I am trying to force read the stream in the Validate stage but it is not working.

    Do I need to write a custom Disassemble code for forcing a read on the inputstream in the pipeline?

    Friday, November 20, 2015 3:02 PM
  • You don't need a custom Disassembler, just a regular component.

    In there, all you need to do is copy the current stream to a VirtualStream, then replace the current stream with your new VirtualStream.  Don't forget to reset the Position back to 0.

    Friday, November 20, 2015 6:56 PM
  • Hi Juhi,

    You don't need any custom disassembler because Regular XML Disassembler will only take care of the property promotion. But as John said as it works in Streaming fashion so it's not promoted rightaway.

    In my case I created a regular pipeline component and just before performing my custom logic I forced a read operation, please see the below screenshot. Here I have performed forced read using stream.

    //Reading message data using Stream, this will not have any performance implication.System.IO.MemoryStream ms = new MemoryStream();originalStream.CopyTo(ms); ms.Position = 0; inmsg.BodyPart.Data = ms;As shown in below image.  

    You can use the same code as is, and later perform your custom logic, as I am reading values of promoted properties.

    Later you can create a pipeline with XMLDisassembler component in Disassemble stage and your custom pipeline in validate stage, as shown below

    Let us know if you still have any issue.


    Thanks,
    Prashant

    My BizTalk Blog
    -------------------------------------------------------------------------
    Please mark this post accordingly if it answers your query or is helpful.

    Sunday, November 22, 2015 7:20 AM
  • Not working. Below is exact code which I am using.

        Stream originalStream = inmsg.BodyPart.GetOriginalDataStream();
                VirtualStream destStream = new VirtualStream();
                byte[] tempBuffer = new Byte[4096];
                int readi = 0;
                while ((readi = originalStream.Read(tempBuffer, 0, tempBuffer.Length)) != 0)
                {
                    destStream.Write(tempBuffer, 0, readi);
                }
                inmsg.BodyPart.Data = destStream;
                originalStream = inmsg.BodyPart.Data;
                originalStream.Position = 0;

    Monday, November 23, 2015 3:55 PM
  • I am still getting null value for promoted properties when i use below code:

    Stream originalStream = inmsg.BodyPart.GetOriginalDataStream();

    System.IO.MemoryStream ms = new MemoryStream();
    originalStream.CopyTo(ms);
    ms.Position = 0;
    inmsg.BodyPart.Data = ms;

    Monday, November 23, 2015 4:03 PM
  • Just a couple things...

    You can use the .CopyTo() method on the Stream class:

      originalStream.CopyTo(destStream);

    You have to reset the pointer on the new stream, destStream, not originalStream:

      destStream.Position = 0;

    Not sure what these are for, but they are not needed:

      originalStream = inmsg.BodyPart.Data;
      originalStream.Position = 0;

    Monday, November 23, 2015 4:08 PM
  • Hi Juhi, 

    could you paste the code for pipeline component you have written here, also attach the screenshot of custom pipeline you have created. May be we are missing something very small but relevant. 


    Thanks,
    Prashant

    My BizTalk Blog
    -------------------------------------------------------------------------
    Please mark this post accordingly if it answers your query or is helpful.

    Monday, November 23, 2015 4:56 PM
  • Please clarify, the message content is published to the MessageBox but the Promoted Properties remain null when you read them in the Pipeline.

    Very important: Do the Properties appear Promoted in BizTalk Administrator? You can check by Stopping the Send Port or Orchestration that will receive the message, then view the properties.


    • Edited by Johns-305MVP Tuesday, November 24, 2015 11:33 AM
    Monday, November 23, 2015 7:25 PM
  • Please clarity, the message content is published to the MessageBox but the Promoted Properties remain null when you read them in the Pipeline.

    Not really, I was able to read promoted properties within the pipeline itself it wasn't coming as null.

    I had just performed forced read operation using XMLDocument or Stream. You can check the article here.

    VERY STRANGE BEHAVIOR OF XML DISASSEMBLER- PROPERTY PROMOTION NOT HAPPENING PROPERLY


    Thanks,
    Prashant

    My BizTalk Blog
    -------------------------------------------------------------------------
    Please mark this post accordingly if it answers your query or is helpful.

    Tuesday, November 24, 2015 9:11 AM
  • Yes John,

    I am able to see the context properties promoted when I stop the send port but it always throws null when I try to read it in pipeline.

    With orchestration I am able to read the properties which means that receive pipeline is unable to read those promoted properties. 

    I tried your suggested workarounds but nothing seems to be working in the pipeline.

    Thursday, November 26, 2015 9:30 AM
  • To clarify, the stream reading component should be the first component in the Validate Stage.

    It should process the message immediately after the XmlDisassembler.

    • Marked as answer by Juhi Gupta Thursday, November 26, 2015 3:29 PM
    Thursday, November 26, 2015 2:19 PM
  • Thanks John and Prashant.

    Finally it worked!!! 

    I combined all disassembler and validate component in same pipeline and deployed the solution. I got the value then populated in the pipeline by below code.

     MemoryStream ms = new MemoryStream();
     originalStream.CopyTo(ms);
     ms.Position = 0;
     inmsg.BodyPart.Data = ms;

    I think the problem was that I was checking the output by debugging the pipeline. I was using separate pipeline for flatfile disassemble and separate to check validate component while debugging, whereas the same pipeline should read XMLdisassembler and Validate custom component. So I deployed the solution. I am still not sure what specific error was there but its gone now. Thanks again for all the help.


    Thursday, November 26, 2015 4:33 PM