How can I un-escape and escape XML in policy?
search cancel

How can I un-escape and escape XML in policy?

book

Article ID: 42866

calendar_today

Updated On:

Products

STARTER PACK-7 CA Rapid App Security CA API Gateway

Issue/Introduction

Issue:

Customers have requested the ability to un-escape and escape XML within policy to be used in requests to be sent through to back-end services or returned in responses to the client.

Cause:

A REST service returns XML which may be invalid. Furthermore, it may contain CDATA elements. This service needs to be called as a SOAP service and the original response to be embedded in the SOAP response message.

As CDATA cannot be nested, the simple option of wrapping it all with CDATA will not work. As the source response is known to be sometimes malformed, XSL cannot be used.

Therefore the only option is escaping the special character.

Environment

Release: L7SMG299000-7.1-Mobile API Gateway-HARDWARE APPLIANCE DUAL CPU
Component:

Resolution

Solution:

This can be accomplished by converting certain characters (" ' < > &) to the escaped representation ('&quot; &apos; &lt; &gt; &amp;') and back again through regular expressions. A policy has been attached to this knowledge base article which outlines how it can be used in a simple example.

A feature enhancement has been logged to add this functionality to Encode/Decode Assertion.

Attachments:

Attachments

1558534528279TEC0000001154.zip get_app