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/03/09 20:28:47 UTC
How to use JAX-RS ClientBuilder to post plain text?
I have to make a pseudo-REST call to a URL within our enterprise. The required POST data is somewhat "mutant". It needs to look like the following:
--------------
xmlMessage=<message type=\"contact.send.message\" id=\"$FROM_USERID\" password=\"$FROM_PASSWORD\" contactId=\"$TO\"> <statement from=\"$FROM_USERID\" to=\"$TO\" text=\"$MSG\" type=\"meeting\"/></message>
--------------
It's mostly XML, but it needs to begin with "xmlMessage=". Since I'm doing this in a CXF-based JAX-RS REST service, I figure I should use the facilities already provided, being the JAX-RS ClientBuilder, but I can't figure out how to just send plain text.
Can someone show me the required pieces to do this?
Re: How to use JAX-RS ClientBuilder to post plain text?
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi David
Client client = ClientBuilder.newClient();
WebTarget webTarget = client.target(address);
Invocation.Builder builder = webTarget.request();
Response r = builder.post(Entity.text(new Book("Book", 126L)));
some of this code can be collapsed, many options are there, you will
find it easy once you start typing the code...
Sergey
On 09/03/17 20:28, KARR, DAVID wrote:
> I have to make a pseudo-REST call to a URL within our enterprise. The required POST data is somewhat "mutant". It needs to look like the following:
> --------------
> xmlMessage=<message type=\"contact.send.message\" id=\"$FROM_USERID\" password=\"$FROM_PASSWORD\" contactId=\"$TO\"> <statement from=\"$FROM_USERID\" to=\"$TO\" text=\"$MSG\" type=\"meeting\"/></message>
> --------------
>
> It's mostly XML, but it needs to begin with "xmlMessage=". Since I'm doing this in a CXF-based JAX-RS REST service, I figure I should use the facilities already provided, being the JAX-RS ClientBuilder, but I can't figure out how to just send plain text.
>
> Can someone show me the required pieces to do this?
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/