cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

SOAP XML /XML Parsing in Thingworx

srepaka
4-Participant

SOAP XML /XML Parsing in Thingworx

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

1 REPLY 1
VladimirN
24-Ruby II
(To:srepaka)

ThingWorx community is here: https://community.ptc.com/t5/IoT-AR/ct-p/IoTAR

Top Tags