Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to ensure the credentials for WebService using Windows
authentication

Answer Posted / prasanna

Passing client credentials to a Web service using Windows
authentication

Sometimes a Web Service is under a configuration that
requires Windows Authentication. It is not a problem
for .NET, all you need to do is set your environment to
send the client credentials.
1. First Create a Reference to a Web Service:





To do that just go to the references of your project and
add a Web Reference. Type the URL of your web service. This
will find your Web Service Reference and you can update it.
This will generate the proxy code you need to access your
webservice.

If you try to call your webservice with a call like:

WebReference.MyService pService = new
WebReference.MyService ();
pService.doStuff("A", "B");

You’ll get a HTTP 404 forbidden access exception.

Now to send the user and password to call your service
write some code like the following:

WebReference.MyService pService = new
WebReference.MyService ();
pService.Credentials = new System.Net.NetworkCredential
("user", "password");
pService.doStuff("A", "B");

You can also send the domain name as part of the parameter
to the NetworkCredential class:

pService.Credentials = new System.Net.NetworkCredential
("user", "password","domain");

It will be even better to have your user and password not
in your code but in the configuration file for your
program. You can then use the AppSettings class to access
those properties.

Is This Answer Correct ?    2 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which filter executes first in an asp.net mvc application?

931


will there be any issues adding a table without primary keys to a data model?

1009


What is difference between viewbag and viewdata and tempdata?

959


what is .edmx file and what it contains?

989


Is it possible to combine asp.net webforms and asp.mvc and develop a single web application?

942


Explain how you can send the result back in JSON format in MVC?

933


What are scaffold templates in mvc?

960


How we can invoke child actions in ASP.Net MVC?

1053


What are advantages of Dependency Injection (DI) in ASP.Net MVC?

1032


Can I set the unlimited length for "maxjsonlength" property in config?

957


Explain test driven development (tdd) ?

958


Explain what platforms does the .net framework run on?

973


What is difference between html.beginform and ajax.beginform?

938


What is needed for running an application built on winfx on the .net framework 3.0?

887


How do you assign a value to a complex number 7 how has exception hand changed in .net framework 4.0?

883