BizTalk - Assign value to Message with xPath - Asked By jeppe svendsen on 18-Jan-11 02:05 AM

Hello

I am constructing a message in an orchestration.

I am trying to assign a value but it does not work. I do like this

xpath(Message_Response,"number(/*[local-name()='ProcessPayment' and namespace-uri()='http://SigmaCommon.ProcessPayment']/*[local-name()='IndbetalingsID' and namespace-uri()='']/text())") = tmp_indbetliangsID;

I get this error:

 Exception: System.Xml.XPath.XPathException: Expression must evaluate to a node-set.
   at System.Xml.XPath.XPathNavigator.Select(XPathExpression expr)
   at System.Xml.XPath.XPathNavigator.Select(String xpath)
   at System.Xml.XmlNode.SelectNodes(String xpath)
   at Microsoft.XLANGs.Core.Part.XPathStore(Object rValue, String xpath)
   at SigmaAutomation.Payments.ProcessPayments.segment3(StopConditions stopOn)
   at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)


Before trying to assign the value I can read out the default value with this xPath

xpath(Message_Response,"number(/*[local-name()='ProcessPayment' and namespace-uri()='http://SigmaCommon.ProcessPayment']/*[local-name()='IndbetalingsID' and namespace-uri()='']/text())")

which makes me believe I got the path right.

I have tried without the /text() as well, does not work either.

The node i am trying to set is of type Long.

Anyone have an idea of what I am doing wrong?





iXon Sfeer replied to jeppe svendsen on 31-Jan-11 08:17 AM
This error message: "Expression must evaluate to a node-set" suggests that the xpath tree is not leading to any type of data value.. you may want to use an xpath tester to check that your xpath expression is correct and if so, troubleshoot the xpath expression when you are modifying it to pass it to the message.
Anita replied to jeppe svendsen on 26-May-11 11:12 AM
I got the exact same problem, did you find a solution to this problem?
jeppe svendsen replied to Anita on 26-May-11 10:39 PM
I cheated. Promoted my properties so I did not have to use xPath
Anita replied to jeppe svendsen on 27-May-11 02:04 AM

I had a promoted property issue and desided to use xpath instead. I have added a link to my question about this in the bottom. I actually found a solution to the xpath last nigth. I tried several xpath-notations, and the last option (of course) was working for me. Here are all the xpaths I tried:

Not working:

xpath(tMessage, "string(/*[local-name()='UpdateArchiveStatusRequest' and namespace-uri()='http://STFK/RiM/ExtensP360/Archive/Schemas/1.0/UpdateArchiveStatusRequest']/*[local-name()='InternalCorrElmUpdateArchStatus' and namespace-uri()=''])") = "Something";

Not working:

xpath(Message, "/*[local-name()='UpdateArchiveStatusRequest' and namespace-uri()='http://STFK/RiM/ExtensP360/Archive/Schemas/1.0/UpdateArchiveStatusRequest']/*[local-name()='InternalCorrElmUpdateArchStatus' and namespace-uri()='']/text()") = "Something";

Not working:

//xpath(Message, "string(/*[local-name()='UpdateArchiveStatusRequest' and namespace-uri()='http://STFK/RiM/ExtensP360/Archive/Schemas/1.0/UpdateArchiveStatusRequest']/*[local-name()='InternalCorrElmUpdateArchStatus' and namespace-uri()='']/text())") = "Something";

Working:

xpath(Message, "/*[local-name()='UpdateArchiveStatusRequest' and namespace-uri()='http://STFK/RiM/ExtensP360/Archive/Schemas/1.0/UpdateArchiveStatusRequest']/*[local-name()='InternalCorrElmUpdateArchStatus' and namespace-uri()='']") = Something";

Link to my question about promoted property:
http://www.biztalkgurus.com/biztalk_server/biztalk_2009/f/32/p/18273/33813.aspx#33813