Caling webservice from code file
This code - snippet shows how you can call the webservice from the code file of a web application. When we add reference to a webservice it generates a proxy file and the CustomerService.ClientConfig file which specifies the configuration needed to access the web service. but here we are going to see how we can use our own binding, webservice url to connect to the web service .
This code - snippet shows how you can call the webservice from the code file of a web application. When we add reference to a webservice it generates a proxy file and the CustomerService.ClientConfig file which specifies the configuration needed to access the web service. but here we are going to see how we can use our own binding, webservice url to connect to the web service .
Assuming that proxy is a variable which refers to our webservice.
CustomerServiceClient proxy = new CustomerServiceClient(new BasicHttpBinding(), new EndpointAddress("http://services.myApp.com/CustomerService.svc"));
proxy.GetCountofUsersCompleted+= new EventHandler
proxy.GetCountofUsersCompletedAsync(1);
void proxy_GetCountofUsersCompleted(object sender, CountUsersCompletedEventArgs e)
{
if (e.Error != null)
{
userCountResult.Text = "Error getting the number of users.";
}
else
{
userCountResult.Text = "Number of users is : " + e.Result;
}
}