Webservice and Credentials

If the Webservice is in "Integrated Windows authentication". We need to
give the credentials for access the Webservice.

How to set the weservice as "Integrated Windows authentication"

1. Start -> Control Panel -> Administrative Tools -> Internet Information Services.
2. Locate the MyWebService virtual directory.
3. Right click the MyWebService -> Properties.
4. Click the Directory Security tab -> Anonymous access and authentication control 5. Click Edit.
6. In the Authentication Methods dialog box,select the check box for Integrated Windows authentication.


Name space required


using System.Net;


Simple code to access the webservice.


private void Page_Load(object sender, System.EventArgs e)
{
localhost.Service1 MyService = new localhost.Service1();
Response.Write( MyService.HelloWorld());
}

The above code will give you "Access Denied error message"

How to solve this?. We have to give the "Credential" for the webservice.
The code follows



private void Page_Load(object sender, System.EventArgs e)
{

localhost.Service1 MyService = new localhost.Service1();
MyService.Credentials = System.Net.CredentialCache.DefaultCredentials;
Response.Write( MyService.HelloWorld());
}





By
Nathan


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: