2976 views

Configuring SOAP requests to return qualified responses

 

Problem
Some web service clients may consider SOAP responses from a ServiceNow instance to be invalid.

 

Symptoms

The web service client encounters one of these errors: 

  • The SOAP response from the ServiceNow Web service is invalid
  • The SOAP response cannot be parsed
  • The namespace is missing in the SOAP response

  

Cause
By default, response elements in ServiceNow SOAP responses are not qualified. Some web service clients may only accept qualified responses.

All elements within a qualified schema must be associated with a namespace. This association is made by prepending an element with a prefix defined by an xmlns attribute. It is also possible to specify a qualified namespace without a prefix in a qualified schema. This is known as the default namespace. All global elements within an unqualified schema must be associated with a namespace, and all child elements must not be associated with a namespace. The default namespace is invalid when used in an unqualified schema.

The examples below show how an element may specify a namespace, or use the default namespace.
 
Qualified, namespace specified Qualified, default namespace Unqualified, namespace specified Unqualified, default namespace (invalid XML)
<snow:parent xmlns:snow="https://servicenow.com/snow">
    <snow:child>I am qualified</snow:child>
</snow:parent>
<parent xmlns="https://servicenow.com/snow">
    <child>I am qualified too</child>
</parent>
<snow:parent xmlns:snow="https://servicenow.com/snow">
    <child>I am unqualified</child>
</snow:parent>
<parent xmlns="https://servicenow.com/snow">
<child>I am not a valid XML document</:child>
</parent>

For more information on qualified and unqualified responses, refer to these documents:



Resolution

Perform one of these actions to resolve the issue:
  • Set the system property glide.wsdl.schema.UnqualifiedElementFormDefault to false. Setting this property to false causes all inbound SOAP traffic to return qualified responses.
  • Include the request parameter elementFormDefault=qualified in the request URI. For example, use <instance>.service-now.com/<table_name>.do?WSDL&elementFormDefault=qualified to obtain a qualified WSDL, or use <instance>.service-now.com/<table_name>.do?SOAP&elementFormDefault=qualified to obtain a qualified response when querying a table
For more information, see the "Setting Namespace Requirements" section in Compatibility for clients generated from WSDL.

Article Information

Last Updated:2016-11-23 16:38:56
Published:2015-01-30