jeudi 2 juillet 2015

How to put xml string in a webresource post() method

This should be an easy task but I'm not finding a fix.

This is what I'm trying to do:

 String input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><usuario><apellido>perez</apellido><idUsuario>21</idUsuario><nombre>pepe</nombre></usuario>";

And then use it here:

ClientResponse response = webResource.accept("application/xml")
               .post(ClientResponse.class, input);

The thing is, I'm trying different strings and such, with ", without, and a valid xml that I've tried and tested, when passed this way, in the client, does not work and returns an error.

So I thought the problem might lie within the Rest client, that might be reading the \ or some similar problem. And I don't really know how to pass a string with " as a character to make a post petition.

Aucun commentaire:

Enregistrer un commentaire