2009-12-04 76 views
1

我已经使用渠道工厂创建了一个WCF客户端。 但我无法连接到另一台机器上的服务器。我得到(407)Prxy身份验证必需的例外。我在哪里可以在我的WCF客户端中指定代理凭证?

WSHttpBinding wsBinding = new WSHttpBinding(); 
     wsBinding.BypassProxyOnLocal = true; 

     EndpointAddress endpoint = 
      new EndpointAddress("http://machineName:7676/MyWCFService"); 
     ChannelFactory<IService> sericeInterface = 
      new ChannelFactory<IService>(wsBinding, endpoint); 

     sericeInterface.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; 
     sericeInterface = sericeInterface.CreateChannel(); 

这是我的客户端连接代码nippet。我在调用服务的方法时遇到异常。

回答

1

看看这个CodePlex链接,试着找到一个与你的密切配合的场景。它提供了如何为不同情况/绑定设置各种证书的清单和示例。

此外这个MSDN link可能有助于Windows身份验证,你似乎正在使用。

要指定凭据,你会需要这样的东西从MSDN链接采取以下:

CalculatorClient cc = new 
    CalculatorClient("WSHttpBinding_ICalculator"); 
// This code returns the WindowsClientCredential type.    
cc.ClientCredentials.Windows.ClientCredential.UserName = GetUserName(); 
cc.ClientCredentials.Windows.ClientCredential.Password = GetPassword(); 
+0

问题是有关代理证书,而不是客户端凭证。 – picrap 2013-04-19 14:00:14

+0

您可以删除或修复此问题吗? – 2013-04-26 13:38:52

相关问题