P
Pete
Hi,
Below is a bit of code that I intend to use to perform a http "Post"
request to an another application - which is still under development.
I would like to verify the implemention of this method ie it will
perform a http POST request with the xml content to the specified URL.
I want to avoid mocking the HttpClient class. I would like to
effectively see this method perform the a actions and and some stub
application receive the request ( get I presume). Any help, with
example code pls, would be very much appreciated.
Thank You.
Pete
code =>
public void sendResponse() {
String url = "URL";
String xmldata = "xml data";
PostMethod post = new PostMethod(url);
final RequestEntity entity = new StringRequestEntity(xmldata);
post.setRequestEntity(entity);
// Specify content type and encoding
post.setRequestHeader("Content-type", "text/xml;
charset=ISO-8859-1");
// Get HTTP client
HttpClient httpclient = new HttpClient();
// Execute request
try {
int result = httpclient.executeMethod(post);
} catch (Exception e) {
System.out.print("exception encountered " + e.toString());
} finally {
post.releaseConnection();
}
}
Below is a bit of code that I intend to use to perform a http "Post"
request to an another application - which is still under development.
I would like to verify the implemention of this method ie it will
perform a http POST request with the xml content to the specified URL.
I want to avoid mocking the HttpClient class. I would like to
effectively see this method perform the a actions and and some stub
application receive the request ( get I presume). Any help, with
example code pls, would be very much appreciated.
Thank You.
Pete
code =>
public void sendResponse() {
String url = "URL";
String xmldata = "xml data";
PostMethod post = new PostMethod(url);
final RequestEntity entity = new StringRequestEntity(xmldata);
post.setRequestEntity(entity);
// Specify content type and encoding
post.setRequestHeader("Content-type", "text/xml;
charset=ISO-8859-1");
// Get HTTP client
HttpClient httpclient = new HttpClient();
// Execute request
try {
int result = httpclient.executeMethod(post);
} catch (Exception e) {
System.out.print("exception encountered " + e.toString());
} finally {
post.releaseConnection();
}
}