none
Property to Check for Blank Xml in Biztalk Server 2006 Orchestration RRS feed

  • Question

  • Hi All...
    I am getting a blank Xml in receive port and i want to check in orchestration whether Xml is Blank or not ..so that i can dump this Xml in a folder if Xml is blank so for this what property should i check ..
    And The Xml i am getting is

    <FETCH_Response xmlns:ns0="http://schemas.microsoft.com/BizTalk/2003">
             
     </FETCH_Response>

    and the schema added in Biztalk Solution is like

    <FETCH_Response xmlns:ns0="http://schemas.microsoft.com/BizTalk/2003">
    <a>test</a>
    <b>test1</b>
             
     </FETCH_Response>

    pls Advice..

    Thanks..
    Sandeep

    Tuesday, March 17, 2009 7:47 AM

Answers

  • Hey Sandeep,

    You can try using xpath in your orchestration. Here is a simple example:

    My simple schema looks something like:
    <ns0:Records xmlns:ns0="http://checkInfInputMessageisEmpty.temp">
      <v_string1>v_string1_0</v_string1>
      <v_string2>v_string2_0</v_string2>
      </ns0:Records>


    1)
    I create a variable to store the string value of v_string1 using xpath.

    In the expression box, 
    v_string1Var = xpath(inpMessage,"string(/*[local-name()='Records']/*[local-name()='v_string1']/text())");

    The "Records" mentioned is the root name and "v_string1" is the element name whose value is being extracted.

    2) Have a Decision shape where you can use :

    System.String.IsNullOrEmpty(v_string1Var)

    -> Note that the variable used above is being initialized in (1) above


    Here you can decide what to do with your message.

    Please let  me know if this approach works for you. Also let me know if you are unclear on how to do any of the above steps.

    Thanks
    -Abhinav-






    Abhinav
    • Marked as answer by Sandeep.Handa Saturday, March 21, 2009 3:45 PM
    Tuesday, March 17, 2009 11:02 AM

All replies

  • Hey Sandeep,

    You can try using xpath in your orchestration. Here is a simple example:

    My simple schema looks something like:
    <ns0:Records xmlns:ns0="http://checkInfInputMessageisEmpty.temp">
      <v_string1>v_string1_0</v_string1>
      <v_string2>v_string2_0</v_string2>
      </ns0:Records>


    1)
    I create a variable to store the string value of v_string1 using xpath.

    In the expression box, 
    v_string1Var = xpath(inpMessage,"string(/*[local-name()='Records']/*[local-name()='v_string1']/text())");

    The "Records" mentioned is the root name and "v_string1" is the element name whose value is being extracted.

    2) Have a Decision shape where you can use :

    System.String.IsNullOrEmpty(v_string1Var)

    -> Note that the variable used above is being initialized in (1) above


    Here you can decide what to do with your message.

    Please let  me know if this approach works for you. Also let me know if you are unclear on how to do any of the above steps.

    Thanks
    -Abhinav-






    Abhinav
    • Marked as answer by Sandeep.Handa Saturday, March 21, 2009 3:45 PM
    Tuesday, March 17, 2009 11:02 AM
  • Hi Abhinav..
    Thanks for your reply..
    To implement the solution youhave provided i developed a simple Biztalk project where i am receiving Xml and then transforming to another Schema and then send it to folder..for this i am using two schema's one for Input and other for Output..
    But i noticed one thing here when i send blank Xml like this:

    <ns0:IN xmlns:ns0="http://schemas.microsoft.com/BizTalk/2003">
     
    </ns0:IN>
    then after transformation in folder i get

    <?xml version="1.0" encoding="utf-8"?>
    <ns0:Out xmlns:ns0="http://schemas.microsoft.com/BizTalk/2003"><c></c><d></d>
    </ns0:Out
    >

    So i am confusing here that how can i get the OPut Xml like this with empty tag's when i gave blank Xml..and why i am getting error with the application which i am using in production server..

    Pls reply..
    Thanks
    Sandeep

    Wednesday, March 18, 2009 8:41 AM
  •  Q: Why do you need to check the XML after you transform the input XML?
                Why don't you first check whether the input XMl is empty? If the XML is not empty then you should decide to transform otherwise take some other action.

    Your application would have a flow like this:

    Receive Location -> Receive Message Shape -> Transform Message Shape (Here you create a string variable and 
    v_string1Var = xpath(inpMessage,"string(/*[local-name()='Records']/*[local-name()='v_string1']/text())") ) -> Decide Shape
    -> If Box (System.String.IsNullOrEmpty(v_string1Var)) -> Your Error processing Logic
    -> Else Box will lead you to Transforming the input message (which you are sure now is a non-empty message) to the output message

    Abhinav
    Wednesday, March 18, 2009 5:17 PM