Hi,

As mentioned earlier

"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)."

Actually , I cannot recreate the message using payloadFactory as you did
because,
   " the message I am modifying with enrich mediator is a "huge and dynamic
response from Third party service". This response I need to modify/enrich
at many places in my service and send it to another third party service as
input.

   so I think I cannot recreate message using payloadFactory like this
   " <format>{"id" : $1, "parts" : $2, "make" : "Tamsung"}</format> "
   as it will be dynamic response from a third party service.

 Please Guide and let me know if I am not clear with my explanation.

 With Regards,
 Aditya


On Wed, Oct 25, 2017 at 2:25 PM, Sudharma Subasinghe <[email protected]>
wrote:

> Hi Aditya,
>
> You can have [] with one json element using PayloadFactory mediator. I
> tried below instead of enrich mediator and it worked for both single
> element and multiple elements.
>
> <payloadFactory media-type="json">
>          <format>{"id" : $1, "parts" : $2, "make" : "Tamsung"}</format>
>           <args>
>                      <arg evaluator="json" expression="$.id"></arg>
>                      <arg evaluator="json" expression="$.parts"></arg>
>           </args>
> </payloadFactory>
>
> Thanks
> Sudharma
>
> On Wed, Oct 25, 2017 at 12:32 PM, Manorama Perera <[email protected]>
> wrote:
>
>> Hi Aditya,
>>
>> In order to preserve the double quotations around the numbers, you can
>> configure the below property in <ESB_HOME>/repository/conf/syn
>> apse.properties
>>
>> synapse.commons.json.output.autoPrimitive=false
>>
>> Thanks,
>> Manorama
>>
>> On Wed, Oct 25, 2017 at 11:31 AM, aditya shivankar <
>> [email protected]> wrote:
>>
>>> 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>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [email protected]
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> Manorama Perera
>> Software Engineer
>> WSO2, Inc.;  http://wso2.com/
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Sudharma Subasinghe,
> Software Engineer,
> WSO2 Inc.
> Email: [email protected] <[email protected]>
> Mobile : +94 710 565 157 <%2B94%20718%20210%20200>
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to