How to get SOAP response status?

mikeg1
Kilo Explorer

Hi All,

I am working on one of the integration with third-party tool. For instance in case of SN Soap integration. When i invoke the web service and get the response can i figure out if that transaction was SUCCESS or FAILURE ? One way to figure out is by going to tags (XML response) and searching if that tag contains any Correlation ID. But is their any way by which i can get httpStatus of transaction like soap-fault, success etc ? Below sample response doesn't contain such status:

<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><insertResponse><sys_id>970f1d638ccd71007f4447f85bcbcb08</sys_id><number>INC0010121</number></insertResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>


PS: .getHttpStatus(); method is returning "undefined".


Thanks in advance,

4 REPLIES 4

Subhajit1
Giga Guru

Hi Manoj,


The error_string field on your ECC Queue should hold the HTTP Response status, and the Business Rule 'ECC Queue - mark outputs state' running on the queue is responsible for this.


Rohant Joshi2
Kilo Expert

Hi Manoj,



After setting all the parameters in your XML when you are posting you soap message


s.post(true);


you can check the   response in the same script. Just check for getHttpStatus.


if (s.getHttpStatus() == '200')


If it is 200 you are getting proper response from the system.


Thanks


davidiol
Kilo Explorer

Hi colleagues,



I'm using the Help the Help Desk Login Script as template to insert data to a custom table with SOAP.



Help the Help Desk Login Script - ServiceNow Wiki



I've launched it from Windows Command Line.



I've modified the script, and it works fine, it insert data on my custom table, but I don't get the '200' response from Service-Now instance.



If I try to write on 'ecc_queue' as the original script does, I get the response so I guess that anywhere there is a script that make the response, but I don't find it.



Anyone knows hot to fix this or how to send the response from SNow ?



Thanks and best regards.