In general, you will only use the Get and post methods to invoke.
- Get method, parameters can be written in the URL.
For example, the server's interface with the @requestparam or @pathvariable, in the client call, can be directly written in the URL, the specific wording I will not write, and the following similar.
- Post method. This is a bit different, and the parameters are written in the body of the request, not inside the URL.
url = url = new URL (http://test.webservice.api/test);
HttpURLConnection connection = (httpurlconnection) url.openconnection ();
Connection.setdooutput (TRUE);
Connection.setdoinput (TRUE);
Connection.setrequestmethod ("POST");
Connection.setusecaches (FALSE);
Connection.setrequestproperty ("Accept-charset", "UTF-8");
Connection.setrequestproperty ("Expect", "100-continue");
...
DataOutputStream WR = new DataOutputStream ();
Wr.writebytes ("parameter=xxx¶meter2=yyy");
Wr.flush ();
Wr.close ();.
....
Reference http://stackoverflow.com/questions/4205980/java-sending-http-parameters-via-post-method-easily
http://blog.csdn.net/j2ee_me/article/details/8848403
Java calls RESTful WebService (RPM)