I am able to access the web service from the web browser but on the same computer if I try to connect to the web service through code I get a The remote server returned an error: (407) Proxy Authentication Required. error.
I have supplied all the credentials required. Here 开发者_高级运维is my code -
MyWebService objWS = new MyWebService();  // my Web service object
// My credentials
System.Net.NetworkCredential cr = new System.Net.NetworkCredential(MyDomainUserName, UserPassword, DomainController);   
System.Net.WebProxy pr = new System.Net.WebProxy(ProxyServer, ProxyPort);
pr.Credentials = cr;   //Using my credentials for the local proxy
// Web Service credentials
System.Net.NetworkCredential cr1 = new System.Net.NetworkCredential("My_WebService_UserName", "My_WebService_Pwd");  
objWS.Credentials = cr1;   // Using WebService credentials to the WS object
//objWS.Credentials = CredentialCache.DefaultCredentials;  // I even tried Using default credentials but this didn't help.
objWS.Proxy = pr;   
Object result = objWS.WebMethod1(param1,param2,param3);
But, this throws an error - The remote server returned an error: (407) Proxy Authentication Required.
Any idea, what am I doing wrong here? Thanks.
You need to update your config file like this to fix this problem.
<system.net>
    <defaultProxy useDefaultCredentials="true"> </defaultProxy>
</system.net>
It isn't clear in this blog post, but this isn't either/or. Both things are required to fix your problem.
http://blogs.msdn.com/b/jpsanders/archive/2009/03/24/httpwebrequest-webexcepton-the-remote-server-returned-an-error-407-proxy-authentication-required.aspx
You get this error because you are trying to access the service from behind a proxy. Try to use this code (you probably only need the last line):
//Set the system proxy with valid server address or IP and port, for example.
System.Net.WebProxy pry = new System.Net.WebProxy("172.16.0.1",8080);
//The DefaultCredentials should be enough.
pry.Credentials = CredentialCache.DefaultCredentials;
GlobalProxySelection.Select = pry;
This means that your proxy needs some credentials(user name and pasword.) Figure out what they are and set them on pry.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论