xpath doesn’t seem to work in BizTalk

Home Page Forums BizTalk 2004 – BizTalk 2010 xpath doesn’t seem to work in BizTalk

Viewing 1 reply thread
  • Author
    Posts
    • #14182

      You need to fully specify the xpath, including namespaces.
      The easiest way to do this is open the schema, select the node and copy the [b:c9a7ccebf4]Instance XPath[/b:c9a7ccebf4] property.

      It should look something like this:
      /*[local-name()=’ContraxMSgs’ and namespace-uri()=’http://MyCompany.MyApp.Messaging.BizTalk’%5D/*%5Blocalname=’ContraxMSg’ and namespace-uri()=’http://MyCompany.MyApp.Messaging.BizTalk’%5D/*%5Blocalname=’MESSAGEID’ and namespace-uri()=’http://MyCompany.MyApp.Messaging.BizTalk’%5D

    • #14183

      Which xpath string produced this error.
      [code:1:465b2e19ff]//ContraxMSgs/ContraxMSg/MESSAGEID[/code:1:465b2e19ff]
      Or
      [code:1:465b2e19ff]/*[local-name()=’ContraxMSgs’ and namespace-uri()=’http://MyCompany.MyApp.Messaging.BizTalk’]/*[localname=’ContraxMSg’ and namespace-uri()=’http://MyCompany.MyApp.Messaging.BizTalk’]/*[localname=’MESSAGEID’ and namespace-uri()=’http://MyCompany.MyApp.Messaging.BizTalk’][/code:1:465b2e19ff]

      Do both xpath strings return the same error?

      • #14184

        Can you email me the schema for this message.
        Can you also save the message that errors and send that as well

        • #14185

          I have a message that looks like this:
          [code:1:b33f97af56]
          <ContraxMSgs xmlns=\"http://MyCompany.MyApp.Messaging.BizTalk\">
          <ContraxMSg>
          <MESSAGEID>177629</MESSAGEID>
          <MESSAGE_TYPE_ID>9</MESSAGE_TYPE_ID>
          <CONTRAX_COMPANY_PARTYID>8147</CONTRAX_COMPANY_PARTYID>
          <SUBJECT>invoice ready.</SUBJECT>
          <TYPE>Invoice Ready</TYPE>
          <PRIORITY>HIGH</PRIORITY>
          <TEXT>Blah Blah. Thank you.</TEXT>
          <EXPIRY_DATE>2004-06-10T00:00:00.0000000-04:00</EXPIRY_DATE>
          </ContraxMSg>
          </ContraxMSgs>
          [/code:1:b33f97af56]
          I’m trying to use an expression shape to get the number of records (even though it is one record everytime) and MessageID. I’m using this xpath:
          [code:1:b33f97af56]
          varTotal = System.Convert.ToInt32(xpath(msgIn, \"count(//ContraxMSg)\"));
          sTemp = xpath(msgIn,\"//ContraxMSgs/ContraxMSg/MESSAGEID\");
          sResult = \"OrcMessaging -> The total number of Messages are \" + System.Convert.ToString(varTotal) + \" MessageID: \" + sTemp;

          System.Diagnostics.Debug.WriteLine(sResult);
          [/code:1:b33f97af56]
          The result though is 0 messages and blank message id. However when I use xmlspy I’m returning 1 message with the correct Message ID so I’m thinking it is the correct xpath.

          How come I’m not getting the right results? Anyone see something that I’ve missed.

          Thanks, Bill N

          • #14186

            Thanks Greg for the reply.

            Again, in XMLSpy the xpath works correctly. However I’m getting this application error in the event viewer:
            [code:1:de243100e0]
            Event Type: Error
            Event Source: XLANG/s
            Event Category: None
            Event ID: 10034
            Date: 8/30/2006
            Time: 3:17:58 PM
            User: N/A
            Computer: XXXXXXX
            Description:
            Uncaught exception terminated service MyCompany.MyApp.Messaging.BizTalk.orcContraxMessaging(e237b0e3-03ee-fc5f-2329-c8bf6a14c367), instance 99654c57-2c08-493f-a2f2-2725c84698f1

            There is an error in the XML document.

            Exception type: InvalidOperationException
            Source: System.Xml
            Target Site: System.Object Deserialize(System.Xml.XmlReader, System.String, System.Xml.Serialization.XmlDeserializationEvents)
            Help Link:
            Additional error information:

            <MESSAGEID xmlns=’http://MyCompany.MyApp.Messaging.BizTalk’> was not expected.

            Exception type: InvalidOperationException
            Source: ranywu4r
            Target Site: System.Object Read2_string()
            Help Link:
            Additional error information:
            [/code:1:de243100e0]

            Looking in HAT I found the message 99654c57-2c08-493f-a2f2-2725c84698f1 as:
            [code:1:de243100e0]
            {817C3D69-744D-4F28-B3EA-D24106632501} {99654C57-2C08-493F-A2F2-2725C84698F1} MyCompany.MyApp.Messaging.BizTalk.orcContraxMessaging http://MyCompany.MyApp.Messaging.BizTalk#ContraxMSgs Receive prtContraxMessages 1/30/2006 3:17:53 PM 1 588 BizTalk Utilities Adapter for Databases Transport database://Oracle Data Provider for .NET/ContraxMsgs/ContraxMsg
            [/code:1:de243100e0]
            A little deeper into HAT, I get:
            [code:1:de243100e0]

            System.InvalidOperationException: There is an error in the XML document. —> System.InvalidOperationException: <MESSAGEID xmlns=’http://MyCompany.MyApp.Messaging.BizTalk’> was not expected. at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderString.Read2_string() — End of inner exception stack trace — at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader) at Microsoft.XLANGs.Core.Part.XPathLoad(Part sourcePart, String xpath, Type dstType) at MyCompany.MyApp.BizTalk.orcContraxMessaging.segment1(StopConditions stopOn) at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
            System.InvalidOperationException
            [/code:1:de243100e0]

            I don’t know if any of this helps. Any ideas what could cause the xpath to error?

            Thanks, Bill N

            • #14187

              This code returns null:
              [code:1:3089b7d000]//ContraxMSgs/ContraxMSg/MESSAGEID[/code:1:3089b7d000]
              This code returns the exception:
              [code:1:3089b7d000]
              /*[local-name()=’ContraxMSgs’ and namespace-uri()=’http://MyCompany.MyApp.Messaging.BizTalk’]/*[localname=’ContraxMSg’ and namespace-uri()=’http://MyCompany.MyApp.Messaging.BizTalk’]/*[localname=’MESSAGEID’ and namespace-uri()=’http://MyCompany.MyApp.Messaging.BizTalk’]
              [/code:1:3089b7d000]
              I thought maybe I’m making some mistake with what I think the schema and/or xml message should look like but in my orchestration I have a receive shape with the correct message and then I have a send shape that just sends the message out to some folder as an xml file.

              Hope this helps (especially as I’m getting desperate)
              Bill N

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