---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Scripted SOAP web services

# Scripted SOAP web services {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read

Scripted SOAP web services allow a ServiceNow administrator to create custom
SOAP web services.

You can define input and output parameters for the SOAP web service and use JavaScript to
perform operations. Though this feature is very powerful, use [direct web services](https://servicenow-prod.fluidtopics.net/IjCXCWB8T1b~VABg1p3Ehw "A direct web service is available for any table in the system if the correct access control list is configured.") or [SOAP web service
import sets](https://servicenow-prod.fluidtopics.net/o4w~bMrulhK9P03ch94d0Q "Web service import sets complement direct web services and scripted SOAP web services by providing a web service interface to import sets tables.") whenever possible since they are simpler to implement and maintain.

## Security

Scripted SOAP web services have the same base security options as all SOAP web services.
For details on SOAP web services security, see [SOAP web services security](https://servicenow-prod.fluidtopics.net/sTBQth13zJB9qSZPTI08ng#c_SOAPWebService__SOAP-web-services-security).

When [strict security](https://servicenow-prod.fluidtopics.net/sTBQth13zJB9qSZPTI08ng "Simple Object Access Protocol (SOAP) is an XML-based protocol for accessing web services over HTTP.") is enforced on
a system, the HTTP authenticated user must have the [soap_script](https://servicenow-prod.fluidtopics.net/sTBQth13zJB9qSZPTI08ng "Simple Object Access Protocol (SOAP) is an XML-based protocol for accessing web services over HTTP.") role to execute the scripted
web service.

## WSDL {#c_ScriptedWebServices__section_px4_kjf_f3b}

All ServiceNow tables and import
sets dynamically generate Web Service Definition Language (WSDL) XML documents that describe
its table schema and available operations.

## Enforcing WSDL compliance {#c_ScriptedWebServices__section_ay4_vff_f3b}

You can force the response to list output values in the same order as defined in the
WSDL.

When you create a scripted SOAP web service, the generated WSDL is based on the Input
Parameters and Output Parameters related lists. The actual SOAP response sent by the
scripted service is determined by the Script. This behavior can cause
the script to return output values in a different order than defined in the WSDL.  
To enforce the order of output parameters as defined in the related list, select the WSDL Compliance check box. When this check box is selected, the web service reorders the parameters returned by the script to match the order in the WSDL.  
Note:  
If additional response parameters are returned by the script, but are not defined in the Response Parameters related list, those parameters are excluded from the response when WSDL Compliance is selected.  
{#c_ScriptedWebServices__table_ump_jgf_f3b__entry__2}

| Parameter | Order |
|-|-|
| Param 1 | 200 |
| Param 2 | 300 |
| Param 3 | 100 |
[Table 1. Output Parameters related list]

{#c_ScriptedWebServices__table_ump_jgf_f3b}

The following is the script that sets values for the defined output parameters. Note that
in this example script the parameters are set in a different order than defined in the
Output Parameters related list. Also note the additional parameter
param4 that is not defined in the related list.

    Response.param1 = 1;
    Response.param4 = 4;
    Response.param3 = 3;

When the WSDL Compliance check box is false,
the SOAP response generated by the script is the following:

    <response>
                    <param1>1</param1>
                    <param4>4</param1>
                    <param3>3</param1>
    </response>

When the WSDL Compliance check box is true, the SOAP response generated by the script is the following:

    <response>
                    <param3>3</param1>
                    <param1>1</param1>
    </response>

## Static WSDL {#c_ScriptedWebServices__section_yfd_p2f_f3b}

Some web service clients require SOAP access to your instance through a specific WSDL
format. This required format may differ from the standard ServiceNow WSDL format. In these
cases you can create a static WSDL that matches the required format.

## Global variables

To facilitate custom processing of incoming SOAP requests, the following global variables are available in the script context:

* soapRequestDocument: Java org.w3c.dom.Document object representing the incoming SOAP envelope.
* soapRequestXML: String object representing the incoming SOAP envelope XML.
* request: Javascript object that contains mapped values (mapped to input parameter names) of the incoming SOAP envelope.
* response: Javascript object that allows you to customize the response values. See [Customize
  Response](https://servicenow-prod.fluidtopics.net/QmUdVVlj9Fr05w2mk5hSoA "Follow this example to customize and control the XML payload of a SOAP response.")
{#c_ScriptedWebServices__ul_qxr_xw2_f3b}
* **[Create a new scripted SOAP web service](https://servicenow-prod.fluidtopics.net/Nwc7plVFBg~KWScAzj_QCw)**   
  Follow these examples to create a new scripted SOAP web service.
* **[Customize response](https://servicenow-prod.fluidtopics.net/QmUdVVlj9Fr05w2mk5hSoA)**   
  Follow this example to customize and control the XML payload of a SOAP response.
* **[Create a scripted SOAP web service using a static WSDL](https://servicenow-prod.fluidtopics.net/r2ZeISb09_k2hbLRWMgq5A)**   
  Follow these examples to create a scripted SOAP web service using a static WSDL.

