XML namespace preservation

XML namespace prefixes are retained by default for all XML-based protocols.

Overview

XML-based virtual services deal with payload only in the data models. No XML serialization information, such as namespace declaration or white spaces, is considered there. If virtual services consumers are not using an XML parser correctly, they might not find the data they are looking for in the simulated response message. For example, you can expect some data to be located in a certain position, but data positioning can change due to different white spaces or XML declaration.

Therefore, Service Virtualization has Learn XML Namespace Prefixes enabled by default. This instructs Service Virtualization to learn namespace prefixes and the namespace declaration location from the imported or learned data. During simulation, Service Virtualization uses this information in the XML serialization phase to ensure the resulting message closely resembles the real one. This helps resolve some cases of non-XML parsers issues.

Supported for these messaging protocols: SOAP, XML

Note: Even though the XML namespace preservation feature helps in some cases of non-standard message parsing on the consumer side, consumers of XML-based virtual services should be using standard XML parsers to achieve best compatibility.

Back to top

Preserve namespace prefixes

  1. Prerequisite: Enable the Enable Learning XML Namespace Prefixes feature.
  2. Enable the feature in your virtual service.

    In the Service Description Editor, under XML Schemas, select Learn XML Namespace Prefixes.

  3. Learn or import messages from the real service.

Result: During simulation, prefixes are maintained.

Back to top

Disable the feature

If you disable the feature, Service Virtualization continues to use the learned/imported prefixes. To remove that metadata, you need to relearn or reimport messages after disabling the feature.

Note: For external service calls (Service Call Activities) created in Service Virtualization 2023 or later, the XML namespace prefixes are preserved by default and cannot be turned off.

Back to top