I have a Windows Forms application which requests wcf services from different locations and gets some information from the wsdl. I want to request for credentials by requesting the wsdl file of the services.
My code for the HttpWebRequest:
UriBuilder uriBuilder = new UriBuilder("http://example.com");
uriBuilder.Query = "WSDL";
System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriBuilder.Uri);
webRequest.ContentType = "text/xml;charset=\"utf-8\"";
webRequest.Method = "GET";
webRequest.Accept = "text/xml";
And this is how I tried to avoid the default authentication already (without any success):
System.Net.CredentialCache myCredentialCache = new System.Net.CredentialCache();
NetworkCredential netCred = new NetworkCredential("user", "password");
myCredentialCache.Add(new Uri(uriBuilder.Uri.ToString()), "Basic", netCred);
webRequest.Credentials = netCred;
webRequest.UseDefaultCredentials = false;
webRequest.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequired
I know that some of these is a stupid try, but I don't have any idea. I searched this site for a solution, but found only the ones mentioned above and they aren't working.
Thank you for your help!