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
On Tuesday, April 11, 2017, KARR, DAVID <[email protected]> wrote: > I posted this on SO (http://stackoverflow.com/ > questions/43333855/using-cxf-clientbuilder-how-to-unmarshal-post-response- > 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 http://sberyozkin.blogspot.com Talend - http://www.talend.com
