403: Forbidden exception

  • Thread starter Thread starter Giulio Petrucci
  • Start date Start date
G

Giulio Petrucci

Hi there,

I'm traying to consume a web service over an https:// connection (see
some threads before ;-) ), and I got it:

System.Net.WebException
The request failed with HTTP status 403: Forbidden.
at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
....

Is this because I need to authenticate with username and password? Or is
because of som certificate-related issue?

In the first case (authentication), should I use the following?

Service proxy = new Service(); //new web service proxy instance;
string username = ConfigurationManager.AppSettings["Username"]; //read
username from the config file
string password = ConfigurationManager.AppSettings["Password"]; //read
password from the config file
System.Net.NetworkCredential credentials = new
System.Net.NetworkCredential(username, password);
proxy.Credentials = credentials;

Thanks in advance,
Giulio - Italia
 
Back
Top