There is an error in the XML document : InvalidOperationException



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:
Error:
xlang/s engine event log en07y: 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 adminis07atively 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.S07ing, System.Xml.Serialization.XmlDeserializationEvents)

The following is a stack 07ace that identifies the location where the exception occured

at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, S07ing encodingStyle, XmlDeserializationEvents events)

at Microsoft.XLANGs.Core.Part.XPathLoad(Part sourcePart, S07ing 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 07ace 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, S07ing encodingStyle, XmlDeserializationEvents events)

 


As can be seen in image below, I am 07ying 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.










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 S07ing value it is s07ing(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.



ServerLess360



Comments

Popular posts from this blog

The request has both SAS authentication scheme and 'Bearer' authorization scheme. Only one scheme should be used

Getting Started with Logic Apps - AS2

How to Debug and Trace request in Azure APIM - Portal, Postman, RequestBin