NetXMS Support Forum

English Support => General Support => Topic started by: mashedpotatorocket on December 04, 2023, 05:45:18 PM

Title: Web Service XML with node attributes generates ERROR
Post by: mashedpotatorocket on December 04, 2023, 05:45:18 PM
Hello.

I'm trying to collect data from a web service. The xml data has this format:

<?xml version="1.0" encoding="UTF-8"?>
<Result>
<UserStatus Status="2" StatusFrom="230904080005" ClientType="13,16" Device="tel:0123456789" TerminalCapabilities="1" DeviceStatusFrom="231204092543" OfficeDeviceStatusFrom="230918121327" MobileDeviceStatusFrom="231204092543" ServerTime="231204155632" DisplayName="Full Name">[email protected]</UserStatus>
</Result>

When using DCI parameter WebService1:/Result/UserStatus, I get [email protected] returned.
When trying to collect the value of an attribute, for example WebService1:/Result/UserStatus/Status, I get <<ERROR>> instead of the value 2.

Is the XML parser in NetXMS compliant with the XML standard?
When testing on xmlvalidation.com it says No errors were found, and this PowerShell oneliner demonstrates it should work:

([xml]'<Result><UserStatus Status="2"/></Result>').Result.UserStatus.Status


Thanks in advance.
Title: Re: Web Service XML with node attributes generates ERROR
Post by: Filipp Sudanov on December 08, 2023, 01:43:05 PM
current xml parsing code does not support this. In the future we will consider adding xms parsing library (same as we now have jq to parse json format). You can follow this ticket: https://track.radensolutions.com/issue/NX-2485

Currently you can enable "Process response as plain text" in properties of the web service and use a regex instead of path to get the value
Title: Re: Web Service XML with node attributes generates ERROR
Post by: Filipp Sudanov on January 19, 2024, 12:16:46 PM
XPath was added in 4.5.0, so you can try using this.
Title: Re: Web Service XML with node attributes generates ERROR
Post by: mashedpotatorocket on February 22, 2024, 04:09:04 PM
We upgraded to 4.5.3 today and had a new look on my Web Services. XPath is working perfectly. Thank you!