Null Reference Exception in Orchestration

Home Page Forums BizTalk 2004 – BizTalk 2010 Null Reference Exception in Orchestration

Viewing 1 reply thread
  • Author
    Posts
    • #22342

      Hi I am trying to fetch the value of the XMLMessage inside orchestration using xpath.

      The code, I wrote in message assignment is as under:

      //Get the path of the the first VoidedInfo Element
      VoidInfoPath = System.String.Format(“//IRPVoidedInfo[{0}]”,1);
      XmlDoc = xpath(ReceiveIRPVoidedMSG,VoidInfoPath);

      //Construct Message
      XmlDocMSG = XmlDoc;

      //Fetch the data from the message
      Unit = xpath(XmlDocMSG, “string(/IRPVoidedInfo/UNIT)”);

      Whenever there is 1 or more IRPVoidedInfo element in the received MSG, it works fine. But if an XML comes with no IRPVoidedInfo element, than the orchestration throws “NULL REFERENCE EXCEPTION”. Can anyone please tell me what changes shall I make to avoid this, other than introducing Exception Shape?

      Thanks and regards,

      Kunal

    • #22344

      First in an expression shape get the count of IRPVoidedInfo in the incoming message.

      Then use a decission to perform your operation (for count  > 0)

      use the xpath query:    xpath(IncomingMsg, “count(//*[local-name()=’IRPVoidedInfo’])”)

      Let me know if this helps.

      • #22357

        It works!!!

        I used the decision to get the count of IRPVoidedInfo and check if it is greater than 0.

        Thanks a lot dude.

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.