You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "KARR, DAVID" <dk...@att.com> on 2017/04/14 16:30:13 UTC
Can form encoding use JAXB annotations for field name mapping?
In the past, I've written REST services using XML or JSON in the request and response, using JAXB annotations in POJOs to facilitate the mapping.
I've now started to work on a small set of services that will be using form encoding in the request and response (not my choice). I can certainly get this to work, using either FormProvider.readFrom() or FormUtils.readFrom() to read from a form stream into a Form, and then getting the Map from that, and then getting the values I need to assign to POJO field. I can do something similar writing a POJO to a form.
However, I notice that using this strategy I'm not using any implicit mapping specified in @Xml... annotations in my POJO. I could certainly write the code to do this mapping, but I find it hard to believe this hasn't been done already. Am I missing something?
Re: Can form encoding use JAXB annotations for field name mapping?
Posted by Sergey Beryozkin <sb...@gmail.com>.
That work with the CXF RS client proxies but with the standard API the
only way is to use Form or MultivaluedMap
Sergey
On 14/04/17 22:14, KARR, DAVID wrote:
>> -----Original Message-----
>> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
>> Sent: Friday, April 14, 2017 11:07 AM
>> To: users@cxf.apache.org
>> Subject: Re: Can form encoding use JAXB annotations for field name
>> mapping?
>>
>> You can have a BeanParam annotated parameter which is a bean with each
>> property annotated with FormParam. CXF specific FormParam("") also works
>> Sergey
>
> This is something that can be used on the CLIENT side of a request? All the references I've found refer to FormParam and BeanParam being used in the definition of the service, clearly on the server side, not the client.
>
> I suppose I didn't make this clear. In this case I'm implementing CLIENTS of existing services that I don't control. I'm using ClientBuilder/Client to contact the service.
>
>> On Friday, April 14, 2017, KARR, DAVID <dk...@att.com> wrote:
>>
>>> In the past, I've written REST services using XML or JSON in the
>>> request and response, using JAXB annotations in POJOs to facilitate
>> the mapping.
>>>
>>> I've now started to work on a small set of services that will be using
>>> form encoding in the request and response (not my choice). I can
>>> certainly get this to work, using either FormProvider.readFrom() or
>>> FormUtils.readFrom() to read from a form stream into a Form, and then
>>> getting the Map from that, and then getting the values I need to
>>> assign to POJO field. I can do something similar writing a POJO to a
>> form.
>>>
>>> However, I notice that using this strategy I'm not using any implicit
>>> mapping specified in @Xml... annotations in my POJO. I could
>>> certainly write the code to do this mapping, but I find it hard to
>>> believe this hasn't been done already. Am I missing something?
>>>
>>
>>
>> --
>> Sergey Beryozkin
>>
>> https://urldefense.proofpoint.com/v2/url?u=http-
>> 3A__sberyozkin.blogspot.com&d=DwIBaQ&c=LFYZ-
>> o9_HUMeMTSQicvjIg&r=OsTemSXEn-xy2uk0vYF_EA&m=QdbHTS-
>> a7GPspsc4Z1B0EIdaRIFB2qbVG75I8-7b9DU&s=Q1VIfTK8RvyrhJ8JQUz-n3e-F5j-
>> qdIWVhE17xieo8g&e=
>> Talend - https://urldefense.proofpoint.com/v2/url?u=http-
>> 3A__www.talend.com&d=DwIBaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=OsTemSXEn-
>> xy2uk0vYF_EA&m=QdbHTS-a7GPspsc4Z1B0EIdaRIFB2qbVG75I8-
>> 7b9DU&s=_pGIKfCiC4h6PT9sYKaU_KV_XMdN7TkqBTiucjTSe4Y&e=
RE: Can form encoding use JAXB annotations for field name mapping?
Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Friday, April 14, 2017 11:07 AM
> To: users@cxf.apache.org
> Subject: Re: Can form encoding use JAXB annotations for field name
> mapping?
>
> You can have a BeanParam annotated parameter which is a bean with each
> property annotated with FormParam. CXF specific FormParam("") also works
> Sergey
This is something that can be used on the CLIENT side of a request? All the references I've found refer to FormParam and BeanParam being used in the definition of the service, clearly on the server side, not the client.
I suppose I didn't make this clear. In this case I'm implementing CLIENTS of existing services that I don't control. I'm using ClientBuilder/Client to contact the service.
> On Friday, April 14, 2017, KARR, DAVID <dk...@att.com> wrote:
>
> > In the past, I've written REST services using XML or JSON in the
> > request and response, using JAXB annotations in POJOs to facilitate
> the mapping.
> >
> > I've now started to work on a small set of services that will be using
> > form encoding in the request and response (not my choice). I can
> > certainly get this to work, using either FormProvider.readFrom() or
> > FormUtils.readFrom() to read from a form stream into a Form, and then
> > getting the Map from that, and then getting the values I need to
> > assign to POJO field. I can do something similar writing a POJO to a
> form.
> >
> > However, I notice that using this strategy I'm not using any implicit
> > mapping specified in @Xml... annotations in my POJO. I could
> > certainly write the code to do this mapping, but I find it hard to
> > believe this hasn't been done already. Am I missing something?
> >
>
>
> --
> Sergey Beryozkin
>
> https://urldefense.proofpoint.com/v2/url?u=http-
> 3A__sberyozkin.blogspot.com&d=DwIBaQ&c=LFYZ-
> o9_HUMeMTSQicvjIg&r=OsTemSXEn-xy2uk0vYF_EA&m=QdbHTS-
> a7GPspsc4Z1B0EIdaRIFB2qbVG75I8-7b9DU&s=Q1VIfTK8RvyrhJ8JQUz-n3e-F5j-
> qdIWVhE17xieo8g&e=
> Talend - https://urldefense.proofpoint.com/v2/url?u=http-
> 3A__www.talend.com&d=DwIBaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=OsTemSXEn-
> xy2uk0vYF_EA&m=QdbHTS-a7GPspsc4Z1B0EIdaRIFB2qbVG75I8-
> 7b9DU&s=_pGIKfCiC4h6PT9sYKaU_KV_XMdN7TkqBTiucjTSe4Y&e=
Re: Can form encoding use JAXB annotations for field name mapping?
Posted by Sergey Beryozkin <sb...@gmail.com>.
You can have a BeanParam annotated parameter which is a bean with each
property annotated with FormParam. CXF specific FormParam("") also works
Sergey
On Friday, April 14, 2017, KARR, DAVID <dk...@att.com> wrote:
> In the past, I've written REST services using XML or JSON in the request
> and response, using JAXB annotations in POJOs to facilitate the mapping.
>
> I've now started to work on a small set of services that will be using
> form encoding in the request and response (not my choice). I can certainly
> get this to work, using either FormProvider.readFrom() or
> FormUtils.readFrom() to read from a form stream into a Form, and then
> getting the Map from that, and then getting the values I need to assign to
> POJO field. I can do something similar writing a POJO to a form.
>
> However, I notice that using this strategy I'm not using any implicit
> mapping specified in @Xml... annotations in my POJO. I could certainly
> write the code to do this mapping, but I find it hard to believe this
> hasn't been done already. Am I missing something?
>
--
Sergey Beryozkin
http://sberyozkin.blogspot.com
Talend - http://www.talend.com