locked
Get the message attribute values in Orchestration without using property promotion RRS feed

  • Question

  • I have the following schema :

    Now I want to get the values of FName,LName in orchestration without using any property promotion ?


    Prakash

    Monday, September 22, 2014 7:15 AM

Answers

  • Hi Prakash,

    You can use XPATH function to access and modify the values inside the Orchestration. For Ex

    FName = xpath(InputMessage, "boolean(/*[local-name()='Root' and namespace-uri()='http://TestNamespace/200902']/*[local-name()='IntField' and namespace-uri()=''])");

    where FName could be a variable and the second parameter of xpath can be copied from instance XPATH property of the schema.

    _________________________________________

    Please indicate "Mark as Answer" or "Mark as Helpful" if this post has answered the question

    Regards,

    Rahul Madaan

    biztalkvillage.blogspot.com

    • Marked as answer by Shivay_ Monday, September 22, 2014 7:40 AM
    Monday, September 22, 2014 7:20 AM
  • Hi Prakash,

    You can try using xpath expression to capture the attribute value within the Orchestration.

    Use a Variable shape to store the value.

    Thanks

    Abhishek

    • Marked as answer by Shivay_ Monday, September 22, 2014 7:40 AM
    Monday, September 22, 2014 7:20 AM
  • Hi Prakash,

    To access values in a message, you can use XPath. XPath queries are used to navigate the tree of a given XML document and are typically used within orchestration Message Assignment and Expression shapes. BizTalk XPath queries require two parameters: the first parameter references the XML message, and the second is the query path.

    Syntax,

    variable = xpath(BiztalkMessage,"string(xpath-query)");

    Rachit

    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.

    • Marked as answer by Shivay_ Monday, September 22, 2014 7:40 AM
    Monday, September 22, 2014 7:31 AM
    Moderator
  • There are also multiple ways of creating the Xpath:

    - Full path with namespaces - Rahul Madaan showed this one

    - Full path without namespaces:

    FName = xpath(InputMessage, "string(/*[local-name()='Root']/*[local-name()='IntField'])");

    I think this method is handy if you have multiple schemas with similar structure  but the namespace changes. This is also easier to read and less prone to errors if there are any changes.

    If you for example wanted the node #3, then it would be

    FName = xpath(InputMessage, "string(/*[local-name()='Root']/*[local-name()='IntField'][3]/*[local-name()='IntSubField'])");

    - Jump directly to the field/node you need (this one works for at least xml elements):

     xpath(InputMessage, "string(//*[local-name()='IntField'])");

    I find this useful when picking up key-values from the message, that can be available only once.

    All the examples above are for elements. Since you are picking up value from an attribute, the actual structure is

    varFName = xpath(InputMessage,"string(/*[local-name()='StudentDetails']/*[local-name()='Student']/@*[local-name()='FName'])");

    And to learn the rest of the possibilities of Xpath, like count, different types, more detailed selections of the correct Node (Like example, I want only the one where FNAME = 'MyFName')  You can try something like: http://social.technet.microsoft.com/wiki/contents/articles/6944.biztalk-orchestrations-xpath-survival-guide.aspx

    Also get DanSharp XmlViewer. It will help you quite a bit when fine tuning the xpaths.


    • Proposed as answer by Jari Myllylä Monday, September 22, 2014 7:40 AM
    • Edited by Jari Myllylä Monday, September 22, 2014 7:45 AM
    • Marked as answer by Shivay_ Monday, September 22, 2014 7:58 AM
    Monday, September 22, 2014 7:40 AM

All replies

  • Hi Prakash,

    You can use XPATH function to access and modify the values inside the Orchestration. For Ex

    FName = xpath(InputMessage, "boolean(/*[local-name()='Root' and namespace-uri()='http://TestNamespace/200902']/*[local-name()='IntField' and namespace-uri()=''])");

    where FName could be a variable and the second parameter of xpath can be copied from instance XPATH property of the schema.

    _________________________________________

    Please indicate "Mark as Answer" or "Mark as Helpful" if this post has answered the question

    Regards,

    Rahul Madaan

    biztalkvillage.blogspot.com

    • Marked as answer by Shivay_ Monday, September 22, 2014 7:40 AM
    Monday, September 22, 2014 7:20 AM
  • Hi Prakash,

    You can try using xpath expression to capture the attribute value within the Orchestration.

    Use a Variable shape to store the value.

    Thanks

    Abhishek

    • Marked as answer by Shivay_ Monday, September 22, 2014 7:40 AM
    Monday, September 22, 2014 7:20 AM
  • Hi Prakash,

    To access values in a message, you can use XPath. XPath queries are used to navigate the tree of a given XML document and are typically used within orchestration Message Assignment and Expression shapes. BizTalk XPath queries require two parameters: the first parameter references the XML message, and the second is the query path.

    Syntax,

    variable = xpath(BiztalkMessage,"string(xpath-query)");

    Rachit

    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.

    • Marked as answer by Shivay_ Monday, September 22, 2014 7:40 AM
    Monday, September 22, 2014 7:31 AM
    Moderator
  • There are also multiple ways of creating the Xpath:

    - Full path with namespaces - Rahul Madaan showed this one

    - Full path without namespaces:

    FName = xpath(InputMessage, "string(/*[local-name()='Root']/*[local-name()='IntField'])");

    I think this method is handy if you have multiple schemas with similar structure  but the namespace changes. This is also easier to read and less prone to errors if there are any changes.

    If you for example wanted the node #3, then it would be

    FName = xpath(InputMessage, "string(/*[local-name()='Root']/*[local-name()='IntField'][3]/*[local-name()='IntSubField'])");

    - Jump directly to the field/node you need (this one works for at least xml elements):

     xpath(InputMessage, "string(//*[local-name()='IntField'])");

    I find this useful when picking up key-values from the message, that can be available only once.

    All the examples above are for elements. Since you are picking up value from an attribute, the actual structure is

    varFName = xpath(InputMessage,"string(/*[local-name()='StudentDetails']/*[local-name()='Student']/@*[local-name()='FName'])");

    And to learn the rest of the possibilities of Xpath, like count, different types, more detailed selections of the correct Node (Like example, I want only the one where FNAME = 'MyFName')  You can try something like: http://social.technet.microsoft.com/wiki/contents/articles/6944.biztalk-orchestrations-xpath-survival-guide.aspx

    Also get DanSharp XmlViewer. It will help you quite a bit when fine tuning the xpaths.


    • Proposed as answer by Jari Myllylä Monday, September 22, 2014 7:40 AM
    • Edited by Jari Myllylä Monday, September 22, 2014 7:45 AM
    • Marked as answer by Shivay_ Monday, September 22, 2014 7:58 AM
    Monday, September 22, 2014 7:40 AM
  • Use a Distinguished Field.

    That is what it's for.  Don't worry about 'performance'.

    Monday, September 22, 2014 11:13 AM
    Moderator