I am using below code to fetch some value from response body. Currently this is the response body is returning the value as in xml format. Now i need to convert this response body into html or json format.
Can any one help to convert this
const soapRequest = require('easy-soap-request');
const fs = require('fs');
// example data
const url = 'https://cap.com/ws/apf/ticketing/?WSDL';
const sampleHeaders = {
'user-agent': 'sampleTest',
'Content-Type': 'application/html;charset=UTF-8',
'soapAction': 'https://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl#LatLonListZipCode',
};
const xml = fs.readFileSync('Auto_query_request.txt', 'utf-8');
// usage of module
(async () => {
const { response } = await soapRequest({ url: url, headers: sampleHeaders, xml: xml, timeout: 1000 }); // Optional timeout parameter(milliseconds)
const { headers, body, statusCode } = response;
console.log(headers);
console.log(body);
console.log(statusCode);
})();
result:
{
date: 'Wed, 29 Jul 2020 08:45:56 GMT',
'content-type': 'text/xml; charset=utf-8',
'transfer-encoding': 'chunked',
connection: 'close',
'content-language': 'en'
}
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing"><env:Header><wsa:MessageID>urn:EB6ACD60D17711EA8F1A35236A977E2C</wsa:MessageID><wsa:ReplyTo><wsa:Address>
So and so data
200