Below is the sample service I have created to Highlight the issues I am
facing in my project(where the request and response are very big and these
issues are repeating at many places).

Request :
{
"id" : "3",
"parts" : ["Screen"]
}

Actual Response :
{
    "id": 3,
    "parts": "Screen",
    "make": "Tamsung"
}

Desired Response  :

{
    "id": "3",
    "parts": ["Screen"],
    "make": "Tamsung"
}

-------------------------------------------------------------------------------------------------------------------
Issues :

1.     "parts": "Screen",

       should have been like below

       "parts": ["Screen"],

      i.e. it does not remain array anymore. I understand the array consist
only one element. But the third party system to which the output of this
service is sent as input(request) expects the element as array. So I need
it to be as array.

2.    "id": 3,

should have been like below
"id": "3",
i.e. the string should have been kept as string.


-------------------------------------------------------------------------------------------------------------------
arrayTest.xml :

<?xml version="1.0" encoding="UTF-8"?>
<api context="/arrayTest" name="arrayTest" xmlns="
http://ws.apache.org/ns/synapse";>
    <resource methods="POST GET">
        <inSequence>

            <enrich>
                <source clone="true" type="inline">
                    <make xmlns="">Tamsung</make>
                </source>
                <target action="child" xpath="//jsonObject"/>
            </enrich>
            <enrich>
                <source clone="true" xpath="//jsonObject"/>
                <target type="body"/>
            </enrich>

            <respond/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>
<?xml version="1.0" encoding="UTF-8"?>
<api context="/arrayTest" name="arrayTest" xmlns="http://ws.apache.org/ns/synapse";>
    <resource methods="POST GET">
        <inSequence>
            
            <enrich>
                <source clone="true" type="inline">
                    <make xmlns="">Tamsung</make>
                </source>
                <target action="child" xpath="//jsonObject"/>
            </enrich>
            <enrich>
                <source clone="true" xpath="//jsonObject"/>
                <target type="body"/>
            </enrich>
            
            <respond/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to