> -----Original Message----- > From: Sergey Beryozkin [mailto:[email protected]] > Sent: Tuesday, April 11, 2017 11:26 AM > To: [email protected] > Subject: Re: Better way to get post response parameters into a POJO? > > The easiest way is to delegate to Cxf FormEncodingProvider (set to a > field in your custom provider) and in your provider's readFrom you'd get > the Form from the Cxf provider and convert HTH Sergey
I did notice FormEncodingProvider, but I didn't understand how to use it. Is there an example that looks sort of like my problem? > On Tuesday, April 11, 2017, KARR, DAVID <[email protected]> wrote: > > > > -----Original Message----- > > > From: Sergey Beryozkin [mailto:[email protected] <javascript:;>] > > > Sent: Tuesday, April 11, 2017 9:42 AM > > > To: [email protected] <javascript:;> > > > 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 <[email protected] > > > <javascript:;>> > > 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=t5H > > > > 1VVQ > > > > JcPekInd0PePjrjSEVSkWQBuWPEFhDlrQ62A&s=RZgen5CwkecIc_3aDZCfdv4Mggc > > > > Ct_7 > > > > MwGPZWv3gLXw&e= > > > > questions/43333855/using-cxf-clientbuilder-how-to-unmarshal-post-r > > > > espo > > > > 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=SjdRkGU > > > eJQe > > > 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=Johgjpb > > > XgXz > > > hcMmAnCzGU135vYCDCXC6eiNQlciJx8U&e= > > > > > -- > 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=Z3MDdgEEFVaho1KNQqcr1vnZLFJPCELnEzkCKwl- > 6SM&s=_SkKKEEORoPi1yMyEAsc8zgCXkgMzzKV8YIM44MeeFY&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=Z3MDdgEEFVaho1KNQqcr1vnZLFJPCELnEzkCKwl- > 6SM&s=iF2VnZVk4kcGcibMMqo6-B0PpaQHMGH6JAwu_jQOJYg&e=
