,我号召Web服务的方法,从后面用下面的代码代理服务器:调用使用SSL C#web服务 - “(401)未经授权”
myWebService.TestWebService webservice = new myWebService.TestWebService();
webservice.Url = "http://test.com/webservice?wsdl";
WebProxy proxy = new WebProxy("1.2.3.4", 8080);
proxy.Credentials = new NetworkCredential("username", "password");
webservice.Proxy = proxy;
string response = webservice.TestWebMethod();
这使用HTTP时工作正常,我在'响应'字符串中得到了我期待的回复。 但是 - 如果我将URL更改为HTTPS,那么我会得到一个(401)未经授权的响应。
如果我把URL放入我的浏览器,它可以正常使用HTTP或HTTPS。
我已经添加了代码来处理SSL证书验证,通过创建一个System.Net.ServicePointManager.ServerCertificateValidationCallback
委托,但代码从来没有得到这么多。该请求在验证证书之前被拒绝,或者看起来像这样。
任何帮助,非常感谢......
我已经更新了我的答案。 – stevehipwell 2009-04-28 15:17:21
你能否用更多的细节更新问题(例如,当你尝试添加引用时,VS会发生什么)? – stevehipwell 2009-04-28 15:56:23