Hi Team,
I have one user case to extract the error message from a SOAP web servie response. The XML is below and my question is how to retrieve the error message from "<ns3:tt_msg_desc>ERROR: Invalid User ID/Password.</ns3:tt_msg_desc>"? I have tried the get XML element attribute and value, but I met problem with the name space in XPATH. Appreciate some one can shed some light.
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:actor="" soapenv:mustUnderstand="0">urn:services-qad-com:</wsa:To>
<wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:actor="" soapenv:mustUnderstand="0"></wsa:Action>
<wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:actor="" soapenv:mustUnderstand="0">urn:messages-qad-com:2022-10-09T22:45:17-0500</wsa:MessageID>
<wsa:RelatesTo xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:actor="" soapenv:mustUnderstand="0">urn:services-qad-com::QADERP</wsa:RelatesTo>
</soapenv:Header>
<soapenv:Body>
<ns1:maintainDailyLeadPriceResponse xmlns:ns1="urn:schemas-qad-com:xml-services" xmlns="urn:schemas-qad-com:xml-services">
<ns1:result>error</ns1:result>
<ns2:dsSessionContext xmlns:ns2="urn:schemas-qad-com:xml-services:common">
<ns2:ttContext>
<ns2:propertyQualifier>QAD</ns2:propertyQualifier>
<ns2:propertyName>domain</ns2:propertyName>
<ns2:propertyValue>PSCN</ns2:propertyValue>
</ns2:ttContext>
<ns2:ttContext>
<ns2:propertyQualifier>QAD</ns2:propertyQualifier>
<ns2:propertyName>scopeTransaction</ns2:propertyName>
<ns2:propertyValue>false</ns2:propertyValue>
</ns2:ttContext>
<ns2:ttContext>
<ns2:propertyQualifier>QAD</ns2:propertyQualifier>
<ns2:propertyName>version</ns2:propertyName>
<ns2:propertyValue>ERP3_1x</ns2:propertyValue>
</ns2:ttContext>
<ns2:ttContext>
<ns2:propertyQualifier>QAD</ns2:propertyQualifier>
<ns2:propertyName>mnemonicsRaw</ns2:propertyName>
<ns2:propertyValue>false</ns2:propertyValue>
</ns2:ttContext>
<ns2:ttContext>
<ns2:propertyQualifier>QAD</ns2:propertyQualifier>
<ns2:propertyName>username</ns2:propertyName>
<ns2:propertyValue>xxxx</ns2:propertyValue>
</ns2:ttContext>
<ns2:ttContext>
<ns2:propertyQualifier>QAD</ns2:propertyQualifier>
<ns2:propertyName>password</ns2:propertyName>
<ns2:propertyValue>******</ns2:propertyValue>
</ns2:ttContext>
<ns2:ttContext>
<ns2:propertyQualifier>QAD</ns2:propertyQualifier>
<ns2:propertyName>action</ns2:propertyName>
<ns2:propertyValue/>
</ns2:ttContext>
<ns2:ttContext>
<ns2:propertyQualifier>QAD</ns2:propertyQualifier>
<ns2:propertyName>entity</ns2:propertyName>
<ns2:propertyValue/>
</ns2:ttContext>
<ns2:ttContext>
<ns2:propertyQualifier>QAD</ns2:propertyQualifier>
<ns2:propertyName>email</ns2:propertyName>
<ns2:propertyValue/>
</ns2:ttContext>
<ns2:ttContext>
<ns2:propertyQualifier>QAD</ns2:propertyQualifier>
<ns2:propertyName>emailLevel</ns2:propertyName>
<ns2:propertyValue/>
</ns2:ttContext>
</ns2:dsSessionContext>
<ns3:dsExceptions xmlns:ns3="urn:schemas-qad-com:xml-services:common">
<ns3:temp_err_msg>
<ns3:tt_level xsi:nil="true"/>
<ns3:tt_msg_context/>
<ns3:tt_msg_data/>
<ns3:tt_msg_datetime>2022-10-09T22:45:16-0500</ns3:tt_msg_datetime>
<ns3:tt_msg_desc>ERROR: Invalid User ID/Password.</ns3:tt_msg_desc>
<ns3:tt_msg_field/>
<ns3:tt_msg_index>0</ns3:tt_msg_index>
<ns3:tt_msg_keys/>
<ns3:tt_msg_keys/>
<ns3:tt_msg_keys/>
<ns3:tt_msg_keys/>
<ns3:tt_msg_keys/>
<ns3:tt_msg_keys/>
<ns3:tt_msg_nbr>MfgProErrorMessage</ns3:tt_msg_nbr>
<ns3:tt_msg_processed>false</ns3:tt_msg_processed>
<ns3:tt_msg_sev>error</ns3:tt_msg_sev>
</ns3:temp_err_msg>
<ns3:temp_err_msg>
<ns3:tt_level xsi:nil="true"/>
<ns3:tt_msg_context/>
<ns3:tt_msg_data/>
<ns3:tt_msg_datetime>2022-10-09T22:45:16-0500</ns3:tt_msg_datetime>
<ns3:tt_msg_desc>ERROR: Unable to initialize session.</ns3:tt_msg_desc>
<ns3:tt_msg_field/>
<ns3:tt_msg_index>1</ns3:tt_msg_index>
<ns3:tt_msg_keys/>
<ns3:tt_msg_keys/>
<ns3:tt_msg_keys/>
<ns3:tt_msg_keys/>
<ns3:tt_msg_keys/>
<ns3:tt_msg_keys/>
<ns3:tt_msg_nbr>MfgProErrorMessage</ns3:tt_msg_nbr>
<ns3:tt_msg_processed>false</ns3:tt_msg_processed>
<ns3:tt_msg_sev>error</ns3:tt_msg_sev>
</ns3:temp_err_msg>
</ns3:dsExceptions>
</ns1:maintainDailyLeadPriceResponse>
</soapenv:Body>
</soapenv:Envelope>
Solved! Go to Solution.
Hi,
I recommend using the local-name function as follows.
//*[local-name()='tt_msg_desc']/text()
Regards,
kinuasa
Sample Flow:
XML.ReadFromFile File: $'''C:\\Test\\Sample.xml''' Encoding: XML.FileEncoding.UTF8 XmlDocument=> XmlDocument
XML.ExecuteXPathQuery.ExecuteXPath XmlDocument: XmlDocument XPathQuery: $'''//*[local-name()=\'tt_msg_desc\']/text()''' XPathResults=> XPathResults
LOOP FOREACH CurrentItem IN XPathResults
Display.ShowMessageDialog.ShowMessage Message: CurrentItem Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> ButtonPressed
END
Hi,
I recommend using the local-name function as follows.
//*[local-name()='tt_msg_desc']/text()
Regards,
kinuasa
Sample Flow:
XML.ReadFromFile File: $'''C:\\Test\\Sample.xml''' Encoding: XML.FileEncoding.UTF8 XmlDocument=> XmlDocument
XML.ExecuteXPathQuery.ExecuteXPath XmlDocument: XmlDocument XPathQuery: $'''//*[local-name()=\'tt_msg_desc\']/text()''' XPathResults=> XPathResults
LOOP FOREACH CurrentItem IN XPathResults
Display.ShowMessageDialog.ShowMessage Message: CurrentItem Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> ButtonPressed
END
Thanks for recommendation. The xpath query syntax works, but it is weird that it return me "No element". Do you have any idea about it?
Microsoft.Flow.RPA.Desktop.Modules.SDK.ActionException: XPath expression returned no element. ---> System.ApplicationException: Error in the application.
--- End of inner exception stack trace ---
at Microsoft.Flow.RPA.Desktop.Modules.XML.Actions.Utilities.GetXmlElement(XmlNodeObject xmlNodeObject, String xpathQuery)
at Microsoft.Flow.RPA.Desktop.Modules.XML.Actions.GetXmlElementValue.Execute(ActionContext context)
at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)
Hi,
The reason is that I used xpath query in Get XML element value component which brought me the error message. It did work as it was mentioned in Execute Xpath expression. Thank you all for help.