Thanks Isuru!

On Sun, Mar 6, 2016 at 10:04 AM, Isuru Udana <[email protected]> wrote:

>
>
> On Sat, Mar 5, 2016 at 3:19 PM, Malintha Amarasinghe <[email protected]>
> wrote:
>
>> Hi Isuru,
>>
>> Thanks a lot for the input. I was able to get it working using a handler
>> that replaces the content-type header with text/plain media type. Now a
>> small problem is the client receives the response with text/plain media
>> type. It seems the current PlainTextFormatter [1] has "text/plain" message
>> format hardcoded in getContentType() method, so I guess we will have to use
>> a custom message formatter in order to change it. WDYT?
>>
> +1. We may able to extend from existing formatter.
>
>>
>> Thanks,
>> Malintha
>>
>> [1]
>> https://github.com/wso2/wso2-axis2/blob/master/modules/transport/base/src/main/java/org/apache/axis2/format/PlainTextFormatter.java#L67
>>
>> On Sat, Mar 5, 2016 at 11:49 AM, Isuru Udana <[email protected]> wrote:
>>
>>> Hi Malintha,
>>>
>>> Builder mediator approach is adding lot of overhead to the configuration
>>> as we have to add it for all the APIs in ESB which handles json.
>>> Handling malformed json is a special case. For this special API which
>>> handles malformed json, let's engage an API handler. At the handler in the
>>> response path we can change the content-type.
>>>
>>>
>>> On Saturday, March 5, 2016, Malintha Amarasinghe <[email protected]>
>>> wrote:
>>>
>>>> Hi Isuru,
>>>>
>>>> Thanks for looking in to this.
>>>>
>>>> 1. We have an API and lets say it points to a backend which sometimes
>>>> give invalid payloads with application/json content type.
>>>> 2. We have added a content aware mediator along the mediation flow.
>>>> (Ex: the API is response caching enabled)
>>>> 3. If the backend gives an invalid payload the cache mediator will fail
>>>> when it tries to build the message.
>>>>
>>>> If we had set the PlainTextBuilder/PlainTextFormatter for application/json
>>>> mediatype in axis2.xml, we can overcome the above issue. But the problem
>>>> is, that applies globally to all the APIs / Services etc in ESB. If we
>>>> could set the PlainTextBuilder/PlainTextFormatter for application/json
>>>> content type only to the API we have the problem with the backend while
>>>> keeping default JsonBuilder/JsonFormatter, it would be a better
>>>> solution IMO as our solution would not affect other APIs/Services.
>>>>
>>>> Thanks,
>>>> Malintha
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Sat, Mar 5, 2016 at 10:26 AM, Isuru Udana <[email protected]> wrote:
>>>>
>>>>> Hi Malintha,
>>>>>
>>>>> Can you please explain the use case you are trying to implement using
>>>>> builder mediator.
>>>>>
>>>>>
>>>>> On Saturday, March 5, 2016, Malintha Amarasinghe <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I was trying a sample for Builder Mediator [1] to override the
>>>>>> default message formatter/builder and use
>>>>>> PlainTextBuilder/PlainTextFormatter for application/json content type. As
>>>>>> per the documentation [1] we should be enable
>>>>>> BinaryRealyBuilder/ExpandingMessageFormatter for at least one content 
>>>>>> type
>>>>>> in axis2.xml.
>>>>>>
>>>>>> 1. I tried enabling a different content-type for
>>>>>> BinaryRealyBuilder/ExpandingMessageFormatter and kept the defaults for
>>>>>> application/json type and then tried to override it using the builder
>>>>>> mediator. But then the Builder mediator does not work as expected and it
>>>>>> uses default JsonBuilder/JsonBuilder to build the message.
>>>>>>
>>>>>> 2. If I enable BinaryRealyBuilder/ExpandingMessageFormatter for
>>>>>> application/json in axis2.xml, Builder mediator works as expected.
>>>>>>
>>>>>> Am I doing anything wrong when I am trying the first option? Or is
>>>>>> (2) the correct behaviour and we should
>>>>>> set BinaryRealyBuilder/ExpandingMessageFormatter for the same content 
>>>>>> type
>>>>>> we are trying to override?
>>>>>>
>>>>>> Kindly appreciate your help on this.
>>>>>>
>>>>>> Thanks,
>>>>>> Malintha
>>>>>>
>>>>>> [1] https://docs.wso2.com/display/ESB490/Builder+Mediator
>>>>>>
>>>>>> --
>>>>>> Malintha Amarasinghe
>>>>>> Software Engineer
>>>>>> *WSO2, Inc. - lean | enterprise | middleware*
>>>>>> http://wso2.com/
>>>>>>
>>>>>> Mobile : +94 712383306
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Sent from Mobile
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Malintha Amarasinghe
>>>> Software Engineer
>>>> *WSO2, Inc. - lean | enterprise | middleware*
>>>> http://wso2.com/
>>>>
>>>> Mobile : +94 712383306
>>>>
>>>
>>>
>>> --
>>> Sent from Mobile
>>>
>>
>>
>>
>> --
>> Malintha Amarasinghe
>> Software Engineer
>> *WSO2, Inc. - lean | enterprise | middleware*
>> http://wso2.com/
>>
>> Mobile : +94 712383306
>>
>
>
>
> --
> *Isuru Udana*
> Associate Technical Lead
> WSO2 Inc.; http://wso2.com
> email: [email protected] cell: +94 77 3791887
> blog: http://mytecheye.blogspot.com/
>



-- 
Malintha Amarasinghe
Software Engineer
*WSO2, Inc. - lean | enterprise | middleware*
http://wso2.com/

Mobile : +94 712383306
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to