How to parse soap xml response

Rahul RJ
Giga Sage
Giga Sage

Hi Friends,

I have done remedy to ServiceNow integration using soap web service, Having problem to parse XML response and setting the incident number to ServiceNow custom field named remedy incident number.

soap xml response

<?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:Body>
<ns0:HelpDesk_Submit_ServiceResponse
xmlns:ns0="urn:COL_HPD_IncidentInterface_Create_WS"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns0:Incident_Number>INC000000121114</ns0:Incident_Number>
</ns0:HelpDesk_Submit_ServiceResponse>
</soapenv:Body>
</soapenv:Envelope>

 

Tried XML parsing in the Business rule but no luck

var xmlDoc = new XMLDocument();
xmlDoc.parseXML(responseBody);
var correlationID = xmldoc.getNodeText("//ns0:Incident_Number");

find_real_file.png

1 ACCEPTED SOLUTION

Bhawana Upreti
Tera Guru
Hi,

Can you try the given script in your business rule.

var response = s.execute();
var ResponseBody = response.getBody();
var status = response.getStatusCode();
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(ResponseBody);
var correlationID = xmlDoc.getNodeText("//ns0:Incident_Number");
gs.log(correlationID);

Thanks

View solution in original post

9 REPLIES 9

were you able to copy the value to the custom field?

Thank you Bhawana this code saved my time and solved my issue 🙂 

Thank you

Thank you Bhawana!!

It worked for me!

 

I used in my custom action in my Flow Designer.

 

Obrigado!

sunita3
Kilo Contributor

HI RJ,

 

I am also having the challenge.now you are able to parse the xml responses and map the fields?

 

Regards,

Sunita