You can use the HttpClient to connect to the web service and either post the message content as necessary, or just use the url with the paramaters as required.
For more information, have a look at the Task Parallelism on MSDN
http://msdn.microsoft.com/en-us/library/dd460717.aspx[
^]
There is also a good article(s) on CP
Task Parallel Library: 1 of n[
^]
For eg.
var handler = new HttpClientHandler()
{
Proxy = System.Net.HttpWebRequest.GetSystemWebProxy(),
MaxRequestContentBufferSize = 30 * 10000000
};
_client = new HttpClient(handler, true);
var task = _client.GetStringAsync("http://myservice.asmx?username=theusername&password=thepassword")
.ContinueWith(messageWithResult =>
{
var result = messageWithResult.Result;
});
var dic = new Dictionary<string, string>();
dic.Add("Username", "theusername");
dic.Add("Password", "password");
FormUrlEncodedContent content = new FormUrlEncodedContent(dic);
HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, "http://myservice.asmx");
message.Content = content;
var task = _client.SendAsync(message)
.ContinueWith(messageWithResult =>
{
var readTask = messageWithResult.Result.Content.ReadAsStringAsync().ContinueWith(
stringMessageResult =>
{
var result = stringMessageResult.Result;
});
readTask.Wait();
});
task.Wait();