Friday, May 30, 2008

Calling a web-service

Here I am not concerned about creating a web-service & consuming it. I hope you know this already. But sometimes when you consume the web-service in .NET it throws an exception like 'The request failed with HTTP status 401 : unauthorized'. When you try to run the web-service directly, it runs without fail.


Resolution:

Dim obj As New basicops.operations
obj.Credentials = System.Net.CredentialCache.DefaultCredentials

lblResult.Text = "Result: " & obj.Subtract(Convert.ToInt32(TextBox1.Text), Convert.ToInt32(TextBox2.Text)).ToString()

No comments: