Performing HTTP(S) synchronous GET requests
In this recipe, we will create a WebServiceConnectSynchronous
class that will be able to perform the HTTP GET
requests. In the next recipe, Performing HTTP(S) synchronous POST requests, we will add a method to perform POST requests. If we follow the HTTP specifications to the letter, we would use the HTTP GET request to retrieve data from a server. For example, when you request a web page from a server, you submit a GET request to the server, requesting that the web page be sent to you. If you want to send information to the server, like filling out a form, you would want to submit a POST request.
For an HTTP GET request, if any parameters need to be sent to the service, they should be included in the URL. There are two primary ways to include the parameters in GET requests:
Path parameter: In this method, the parameters are a part of the URL path itself. For example, in the URL http://mytest.com/testservice/value1, the
value1
path element is the...