Apply JSON Transformation - behavioral difference between 9.2 and 9.4

book

Article ID: 144820

calendar_today

Updated On:

Products

CA API Gateway API SECURITY CA API Gateway Precision API Monitoring Module for API Gateway (Layer 7) CA API Gateway Enterprise Service Manager (Layer 7) STARTER PACK-7 CA Microgateway

Issue/Introduction

User noticed a different behaviour of the Apply JSON Transformation in Gateway Version 9.4 compared with the Gateway Version 9.2.

There is an error with the transformation of special Characters inJSON Payload (example String: TESTdiařťeéß).

The Policy in Version 9.2 looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<wsp:Policy xmlns:L7p="http://www.layer7tech.com/ws/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy">

    <wsp:All wsp:Usage="Required">

        <L7p:JsonTransformation>

            <L7p:DestinationMessageTarget MessageTarget="included">

                <L7p:TargetModifiedByGateway booleanValue="true"/>

            </L7p:DestinationMessageTarget>

            <L7p:RootTagString stringValue="result"/>

            <L7p:Target target="REQUEST"/>

            <L7p:Transformation transformation="JSON_to_XML"/>

        </L7p:JsonTransformation>

        <L7p:HardcodedResponse>

            <L7p:Base64ResponseBody stringValue="JHtyZXF1ZXN0Lm1haW5wYXJ0fQ=="/>

        </L7p:HardcodedResponse>

    </wsp:All>

</wsp:Policy>


The Call is working for Version 9.2 and the Special character will be Pre-transformed like this (which is correct). During transforming it back to JSON the client receives the correct special characters:

POST https://dev-msg.xx.xx/test/transformation

200

120ms

Client Certificate

Network

Request Headers

Request Body

test1: {…}

definitionName: "TESTdiařťeéß"

Response Headers

Response Body

<result><test1><definitionName>TESTdiařťeéß</definitionName></test1></result>

 

The Policy in Gateway Version 9.4 is exactly the same:

<?xml version="1.0" encoding="UTF-8"?>

<wsp:Policy xmlns:L7p="http://www.layer7tech.com/ws/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy">

    <wsp:All wsp:Usage="Required">

        <L7p:JsonTransformation>

            <L7p:DestinationMessageTarget MessageTarget="included">

                <L7p:TargetModifiedByGateway booleanValue="true"/>

            </L7p:DestinationMessageTarget>

            <L7p:RootTagString stringValue="result"/>

            <L7p:Target target="REQUEST"/>

            <L7p:Transformation transformation="JSON_to_XML"/>

        </L7p:JsonTransformation>

        <L7p:HardcodedResponse>

            <L7p:Base64ResponseBody stringValue="JHtyZXF1ZXN0Lm1haW5wYXJ0fQ=="/>

        </L7p:HardcodedResponse>

    </wsp:All>

</wsp:Policy>

 

The result of the test shows that the special characters are converted to questions marks. During transforming it back to JSON the client receives questions marks instead of the special characters:

POST https://xx.com/test/transformation

200

388ms

Network

Request Headers

Request Body

test1: {…}

definitionName: "TESTdiařťeéß"

Response Headers

Response Body

<result><test1><definitionName>TESTdia????e????</definitionName></test1></result>

Environment

Release : 9.4

Component : API GTW ENTERPRISE MANAGER, Docker 

Resolution

To fix the issue, users need to set the locale settings LANG to en_US.UTF-8 in docker-compose.yml file.
LANG: en_US.UTF-8