cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "KARR, DAVID" <dk0...@att.com>
Subject RE: Better way to get post response parameters into a POJO?
Date Tue, 11 Apr 2017 16:50:26 GMT
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Tuesday, April 11, 2017 9:42 AM
> To: users@cxf.apache.org
> Subject: Re: Better way to get post response parameters into a POJO?
> 
> Hi, well, if the response data are in the form format then you need to
> read it as a form, but perhaps a cleaner way is to create
> MessageBodyReader for CodeAndMessage, which can convert a form response,
> Cheers Sergey

I guess I was heading in that direction.  Are there examples of creating a MessageBodyReader
from a Form Map?  I'll start reading up on writing MBRs, but it would be good if I had something
similar to start with.

> On Tuesday, April 11, 2017, KARR, DAVID <dk068x@att.com> wrote:
> 
> > I posted this on SO
> > (https://urldefense.proofpoint.com/v2/url?u=http-3A__stackoverflow.com
> > _&d=DwIBaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=OsTemSXEn-xy2uk0vYF_EA&m=t5H1VVQ
> > JcPekInd0PePjrjSEVSkWQBuWPEFhDlrQ62A&s=RZgen5CwkecIc_3aDZCfdv4MggcCt_7
> > MwGPZWv3gLXw&e=
> > questions/43333855/using-cxf-clientbuilder-how-to-unmarshal-post-respo
> > nse- parameters-into-java-cla), but some people might not see it, but
> > might see it here, so I'm asking here also.
> >
> > To put it another way, I have the following code as a base:
> > -------------------
> >         public CodeAndMessage validateToken(String token) {
> >                 WebTarget       target  =
> client.target(getHostPort()).
> > path(getPath());
> >                 Builder request = target.request(MediaType.
> > APPLICATION_JSON_TYPE);
> >                 Form  form    = new Form();
> >                 form.param("TokenID", token);
> >                 Form  responseForm    =
> request.post(Entity.entity(form,
> > MediaType.APPLICATION_FORM_URLENCODED_TYPE), Form.class);
> >                 System.out.println("responseForm[" + responseForm + "]
> > map[" + responseForm.asMap() + "]");
> >                 return new CodeAndMessage().
> >                             errorCode(responseForm.asMap()
> > .getFirst("errorCode")).
> >
> errorMessage(responseForm.asMap().getFirst("
> > errorMessage"));
> >         }
> > ----------------
> >
> > Where "CodeAndMessage" is a simple POJO with two fields.
> >
> > This works, but I was wondering if there is a cleaner way to do this,
> > to avoid having to use the Form response and getting the map values.
> >
> 
> 
> --
> 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=t5H1VVQJcPekInd0PePjrjSEVSkWQBuWPEFhDlrQ62A&s=SjdRkGUeJQe
> WcTlvRwImNayrGo841bzo52GGjT61Tfs&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=t5H1VVQJcPekInd0PePjrjSEVSkWQBuWPEFhDlrQ62A&s=JohgjpbXgXz
> hcMmAnCzGU135vYCDCXC6eiNQlciJx8U&e=
Mime
View raw message