Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hi,
Could someone help me in how to parse soap XML or normal XML in thingworx.
When I'm trying below soap response XML in thingworx I'm getting an error message as below:
TypeError: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <GetHolidaysAvailableResponse xmlns="http://www.holidaywebservice.com/HolidayService_v2/"> <GetHolidaysAvailableResult> <HolidayCode> <Code>NEW-YEARS-DAY-ACTUAL</Code> <Description>New Year Day</Description> </HolidayCode> </GetHolidaysAvailableResult> </GetHolidaysAvailableResponse> </soap:Body></soap:Envelope> is not an xml object. (soap_Test#14)
and my XML will be :
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetHolidaysAvailableResponse xmlns="http://www.holidaywebservice.com/HolidayService_v2/">
<GetHolidaysAvailableResult>
<HolidayCode>
<Code>NEW-YEARS-DAY-ACTUAL</Code>
<Description>New Year's Day</Description>
</HolidayCode>
</GetHolidaysAvailableResult>
</GetHolidaysAvailableResponse>
</soap:Body>
</soap:Envelope>
XML parsing code:
var content = '<?xml version="1.0" encoding="utf-8"?>\
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">\
<soap:Body>\
<GetHolidaysAvailableResponse xmlns="http://www.holidaywebservice.com/HolidayService_v2/">\
<GetHolidaysAvailableResult>\
<HolidayCode>\
<Code>NEW-YEARS-DAY-ACTUAL</Code>\
<Description>New Year Day</Description>\
</HolidayCode>\
</GetHolidaysAvailableResult>\
</GetHolidaysAvailableResponse>\
</soap:Body>\
</soap:Envelope>';
var resultName = content.*::Body.GetHolidaysAvailableResponse.GetHolidaysAvailableResult.HolidayCode.Description;
var result = document.toString();
How to parse soap xml/xml to either string or infotable as 'result'. Any help would be appreciated.
Thanks in Advance