Skip to content

Instantly share code, notes, and snippets.

@zackster
Created April 11, 2012 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackster/2357128 to your computer and use it in GitHub Desktop.
Save zackster/2357128 to your computer and use it in GitHub Desktop.
/**
* Submits a POST request to the given URL with the given XML as an attachment.
*
* @param url
* @param xmlContent
* @return
* @throw IOException
* */
public ContentExchange postXML(String url, String xmlContent) throws IOException {
HttpClient client = getClient();
ContentExchange exchange = new ContentExchange();
exchange.setMethod("POST");
exchange.setURL(url);
exchange.setRequestContent( new ByteArrayBuffer( xmlContent.getBytes("UTF-8") ) );
exchange.setRequestContentType("text/xml;charset=utf-8");
client.send(exchange);
return exchange;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment