tags:

views:

56

answers:

1

Does HttpUnit support getting a response from an HTTP POST with an xml argument?

Edit

If you want to send a post request, you might instantiate a PostMethodWebRequest object.

WebRequest request = new PostMethodWebRequest("http://example.com/thing/create");

And if you want to set parameters for that request, I think what you would do is this:

request.setParameter("attribute", "value");

But what I am looking for is how to make the body of the post an XML document that holds the data for all the attributes I need to create a new Thing. Does anyone know the best way to accomplish that?

A: 

This seems to do the trick:

InputStream body = new FileInputStream("create.xml");
WebRequest request = new PostMethodWebRequest("http://example.com/thing/create", body, "text/xml");
thisgeek