Groups | Search | Server Info | Login | Register
Groups > comp.client-server > #2
| From | Pete <vw_bora@sky.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer, comp.lang.java.help, comp.client-server |
| Subject | Testing the Post request |
| Date | 2011-06-18 04:41 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <df9cb1d7-c953-49ed-851b-c309a034a3a9@x3g2000yqj.googlegroups.com> (permalink) |
Cross-posted to 3 groups.
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();
}
}
Back to comp.client-server | Previous | Next — Next in thread | Find similar
Testing the Post request Pete <vw_bora@sky.com> - 2011-06-18 04:41 -0700
Re: Testing the Post request Stanimir Stamenkov <s7an10@netscape.net> - 2011-06-18 17:42 +0300
Re: Testing the Post request Pete <vw_bora@sky.com> - 2011-06-18 08:54 -0700
Re: Testing the Post request Stanimir Stamenkov <s7an10@netscape.net> - 2011-06-18 19:33 +0300
Re: Testing the Post request Pete <vw_bora@sky.com> - 2011-06-18 10:40 -0700
Re: Testing the Post request Stanimir Stamenkov <s7an10@netscape.net> - 2011-06-18 23:36 +0300
Re: Testing the Post request Pete <vw_bora@sky.com> - 2011-06-18 15:33 -0700
Re: Testing the Post request Abu Yahya <abu_yahya@invalid.com> - 2011-06-19 23:10 +0530
Re: Testing the Post request markspace <-@.> - 2011-06-18 11:11 -0700
csiph-web