Should I add this bean to <jaxrs:providers> section?

WBR, Maxim
(from mobile, sorry for the typos)

On Jan 27, 2017 00:35, "Maxim Solodovnik" <[email protected]> wrote:

MessageBodyWriter<List<AppointmentDTO>> doesn't work :((
Can I set breakpoint somewhere to debug this?

On Fri, Jan 27, 2017 at 12:30 AM, Sergey Beryozkin <[email protected]>
wrote:

> Hi, I won;t have time to investigate it now, but I;d say you'll have to
> type it as
>
> MessageBodyWriter<List<AppointmentDTO>>
>
> give it a try please
>
> Cheers, Sergey
>
> On 26/01/17 17:28, Maxim Solodovnik wrote:
>
>> Sure,
>>
>> Here is the service/method: [1]
>> It is annotated with
>> @Produces({MediaType.APPLICATION_JSON})
>>
>> Method returns List<AppointmentDTO>
>>
>> Body writer is declared as follows:
>>
>> @Provider
>> @Produces({MediaType.APPLICATION_JSON})
>> public class AppointmentMessageBodyWriter implements
>> MessageBodyWriter<AppointmentDTO> {
>>
>> I can commit it and send the link to the github if it helps ....
>>
>> [1]
>> https://github.com/apache/openmeetings/blob/3.2.x/openmeetin
>> gs-webservice/src/main/java/org/apache/openmeetings/webservi
>> ce/CalendarWebService.java#L97
>>
>> On Fri, Jan 27, 2017 at 12:24 AM, Sergey Beryozkin <[email protected]>
>> wrote:
>>
>> It may not be selected, depends on what type is returned, what media type
>>> is set as a response content type, can you provide more info ?
>>>
>>> Cheers, Sergey
>>>
>>> On 26/01/17 17:19, Maxim Solodovnik wrote:
>>>
>>> I have added following bean to my Spring config:
>>>> <bean id="appointmentAppointmentMessageBodyWriter"
>>>> class="org.apache.openmeetings.webservice.util.AppointmentMe
>>>> ssageBodyWriter"
>>>> />
>>>>
>>>> And non of it's methods were called :(
>>>> Am I missing any specific configuration?
>>>>
>>>> On Fri, Jan 27, 2017 at 12:12 AM, Sergey Beryozkin <
>>>> [email protected]>
>>>> wrote:
>>>>
>>>> Yes, ParamConverter works out only on the client side and in only on the
>>>>
>>>>> server side, it is dedicated to a simple conversion of request URI or
>>>>> header parameters (@PathParam, QueryParam, MatrixParam, Cookie,
>>>>> HeaderParam) only
>>>>>
>>>>>
>>>>> Cheers, Sergey
>>>>>
>>>>> On 26/01/17 17:05, Maxim Solodovnik wrote:
>>>>>
>>>>> So I need to create the class like this:
>>>>>
>>>>>> http://memorynotfound.com/jax-rs-messagebodywriter/
>>>>>> And add it as spring bean and it will handle output?
>>>>>>
>>>>>> Why I was thought ParamConverter should convert to both sides: it has
>>>>>> 2
>>>>>> methods: fromString and toString ....
>>>>>>
>>>>>> On Thu, Jan 26, 2017 at 11:59 PM, Sergey Beryozkin <
>>>>>> [email protected]>
>>>>>> wrote:
>>>>>>
>>>>>> Hi Max
>>>>>>
>>>>>>
>>>>>>> This provider only affect the input parameters, what is returned
>>>>>>> from a
>>>>>>> method is technically a message hence MessageBodyWriter is
>>>>>>> responsible
>>>>>>> for
>>>>>>> writing it and MessageBodyReader - for reading it.
>>>>>>>
>>>>>>> ParamConverterProvider only supports PathParam, etc, but not the in
>>>>>>> parameter which represents the body, again, it will be MBR which will
>>>>>>> read
>>>>>>> it.
>>>>>>>
>>>>>>> ParamConverterProvider can be used on the client side to convert the
>>>>>>> parameters in the out flow
>>>>>>>
>>>>>>> HTH, Sergey
>>>>>>>
>>>>>>> On 26/01/17 16:45, Maxim Solodovnik wrote:
>>>>>>>
>>>>>>> Hello All,
>>>>>>>
>>>>>>>
>>>>>>>> I have implemented custom ParamProvider [1] and set it in
>>>>>>>> jaxrs:server
>>>>>>>> [2]
>>>>>>>> It works as expected to convert Incoming parameters for example here
>>>>>>>> [3]
>>>>>>>> But it is not used while writing output JSON :(
>>>>>>>>
>>>>>>>> adding additional provider as follows
>>>>>>>> <jaxrs:providers>
>>>>>>>> <bean id="omParamProvider"
>>>>>>>> class="org.apache.openmeetings.webservice.util.OmParamConver
>>>>>>>> terProvider"/>
>>>>>>>> <bean id="jsonProvider"
>>>>>>>> class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>>>>>>>> <property name="serializeAsArray" value="true"/>
>>>>>>>> </bean>
>>>>>>>> </jaxrs:providers>
>>>>>>>>
>>>>>>>> Also has no effect "serializeAsArray" not working :(
>>>>>>>> CXF 3.1.9
>>>>>>>>
>>>>>>>> Thanks in advance
>>>>>>>>
>>>>>>>>
>>>>>>>> [1]
>>>>>>>> https://github.com/apache/openmeetings/blob/3.2.x/openmeetin
>>>>>>>> gs-webservice/src/main/java/org/apache/openmeetings/
>>>>>>>> webservice/util/OmParamConverterProvider.java
>>>>>>>> [2]
>>>>>>>> https://github.com/apache/openmeetings/blob/3.2.x/openmeetin
>>>>>>>> gs-web/src/main/webapp/WEB-INF/classes/openmeetings-appli
>>>>>>>> cationContext.xml#L285
>>>>>>>> [3]
>>>>>>>> https://github.com/apache/openmeetings/blob/3.2.x/openmeetin
>>>>>>>> gs-webservice/src/main/java/org/apache/openmeetings/
>>>>>>>> webservice/CalendarWebService.java#L97
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>> Sergey Beryozkin
>>>>>>>
>>>>>>> Talend Community Coders
>>>>>>> http://coders.talend.com/
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>> Sergey Beryozkin
>>>>>
>>>>> Talend Community Coders
>>>>> http://coders.talend.com/
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>



-- 
WBR
Maxim aka solomax

Reply via email to