In current application I have requirement to choose the flow based on a field's value. As it can't be distinguished I used Xpath. It's simple, to fetch value following is what needs to be done:
var = xpath(messageOnWhichXpathIstoBeapplied, "xpathQuery");
I did same, but got following error:
xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'Palette.E1.CreateInvoiceE1(0b616f5a-048d-e8d5-b014-91cde67160f9)'.
The service instance will remain suspended until administratively resumed or terminated.
If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
InstanceId: ba30a5f2-c173-4eff-8d31-e1cb9dc8c3b3
Shape name: Get_Status
ShapeId: 7b7bd44c-bf3f-4cd8-ba61-232c818d8271
Exception thrown from: segment 1, progress 6
Inner exception: 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)
The following is a stack trace that identifies the location where the exception occured
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at Microsoft.XLANGs.Core.Part.XPathLoad(Part sourcePart, String xpath, Type dstType)
at Palette.E1.CreateInvoiceE1.segment1(StopConditions stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
Additional error information:
<Status xmlns=''> was not expected.
Exception type: InvalidOperationException
Source: System.Xml
Target Site: System.Object Read_int()
The following is a stack trace that identifies the location where the exception occured
at System.Xml.Serialization.XmlSerializationPrimitiveReader.Read_int()
at System.Xml.Serialization.XmlSerializer.DeserializePrimitive(XmlReader xmlReader, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
Why it Happened
As can be seen in image below, I am trying to assign value of Status field to varStatus variable(of type Int32), looks correct but this is not. Xpath is used to select nodes or node sets from an Xml document, thus if I am using xmlVariable to get the value from below xpath query it would have been correct. Xpath queries do not implicitly do type conversion, thus the error.
What to Do
In order to fetch values other than XML, you need to explicitly specify the Xpath about the type conversion and for that we need to use xpath functions depending upon requirement.
For Number it is number(xpathquery), for String value it is string(xpathquery) , for Boolean value it is boolen(xpathquery) etc.
Thus to get rid of error, I used number xpath function to fetch value from status field, and assigned to varStatus variable of type Int32.
If you have questions or suggestions, feel free to do in comments section below !!!
Do share if you find this helpful .......
Knowledge Sharing is Caring !!!!!!
Very helpful, thank you!
ReplyDelete