Performing HTTP(S) asynchronous GET requests
In this recipe, we will create a WebServiceConnectAsynchronous
class that will be able to perform an HTTP GET
request asynchronously. If we follow the HTTP specifications to the letter, we would be using the HTTP GET
request to retrieve data from a server. For example, when you request a web page from a server, you submit an HTTP GET
request.
For an HTTP GET
request, if any parameters need to be sent to the resource, they should be included in the URL. There are two primary ways to include the parameters in a GET
request:
Path parameter: In this method, the parameters are part of the URL path itself. For example, in the URL http://mytest.com/testservice/value1, the
value1
path element is the parameter.Query parameter: In this method, the parameters are added to the URL at the end of the path as key-value pairs. Let's consider the URL http://mytest.com/testservice?key1=value1&key2=value2. In this URL,
key1
andkey2
are the keys whilevalue1
and...