SOAPResponseV2 - Scoped, Global

The SOAPResponseV2 API allows you to use the data returned by an outbound SOAP message in JavaScript code.

A SOAPResponseV2 object is returned by the SOAPMessageV2 functions execute() and executeAsync().

You can use this API in scoped applications, or within the global scope.

SOAPResponseV2 - getBody()

Get the content of the SOAP response body.

Table 1. Parameters
Name Type Description
None
Table 2. Returns
Type Description
String The SOAP response body.
var body = response.getBody();

SOAPResponseV2 - getCookies()

Get all cookies included in the response.

Table 3. Parameters
Name Type Description
None
Table 4. Returns
Type Description
Object The list of cookies. Iterate through the list to perform operations on each cookie.

var cookies = response.getCookies();
var i;
for(i=0;i<cookies.size();i++) {
   gs.print(‘cookie: ‘ + cookies.get(i));
}
Output:
  • JSESSIONID=4135AA97A5D12DA22EF614AA2B0CAFD8.node20; Path=/; Secure; HttpOnly
  • SABASESSIONID=370152970.36895.0000; path=/

SOAPResponseV2 - getErrorCode()

Get the numeric error code if there was an error during the SOAP transaction.

This error code is specific to the ServiceNow platform, it is not an HTTP error code. Provide this error code if you require assistance from ServiceNow Customer Support.

Table 5. Parameters
Name Type Description
None
Table 6. Returns
Type Description
Number The numeric error code, such as 1 for a socket timeout.
var errorCode = response.getErrorCode();

SOAPResponseV2 - getErrorMessage()

Get the error message if there was an error during the SOAP transaction.

Table 7. Parameters
Name Type Description
None
Table 8. Returns
Type Description
String The error message.
var errorMsg = response.getErrorMessage();

SOAPResponseV2 - getHeader(String name)

Get the value for a specified HTTP header.

Table 9. Parameters
Name Type Description
name String The name of the header that you want the value for, such as Set-Cookie.
Table 10. Returns
Type Description
String The value of the specified header.
var headerVal = response.getHeader("Accept");

SOAPResponseV2 - getHeaders()

Get all HTTP headers returned in the SOAP response and the associated values.

Table 11. Parameters
Name Type Description
None
Table 12. Returns
Type Description
Object An Object that maps the name of each header to the associated value.
var headers = response.getHeaders();

SOAPResponseV2 - getStatusCode()

Get the numeric HTTP status code returned by the SOAP provider.

Table 13. Parameters
Name Type Description
None
Table 14. Returns
Type Description
Number The numeric status code returned by the SOAP provider, such as 200 for a successful response.
var statusCode = response.getStatusCode();

SOAPResponseV2 - haveError()

Indicate if there was an error during the SOAP transaction.

Table 15. Parameters
Name Type Description
None
Table 16. Returns
Type Description
boolean Returns true if there was an error, false if there was no error.
var error = response.haveError();

SOAPResponseV2 - waitForResponse(Number timeoutSecs)

Set the amount of time the instance waits for a response from the web service provider.

This method overrides the property glide.soap.outbound.ecc_response.timeout for this SOAP response.

Table 17. Parameters
Name Type Description
timeoutSecs Number The amount of time, in seconds, to wait for this response.
Table 18. Returns
Type Description
void
response.waitForResponse(60);