English 中文(简体)
Where do I specify proxy credentials in my WCF client?
原标题:

I have created a WCF client using channel factory. But I am not able to connect to a server in another machine. I am getting a (407) Prxy Authentication Required exception.

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();

This is my client connection code nippet. I am getting exception when I call a method of the service.

问题回答

Take a look at this CodePlex link, try to find a scenario that matches closely to yours. It provides checklists and samples of how to set the various credentials for different situations/bindings.

Also this MSDN link might help with Windows Authentication, which you seem to be using.

To assign credentials you ll need something like the below taken from the MSDN link:

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




相关问题
Google Site Data fetching

Hail! I want to fetch image from NOT PUBLIC Google Site s page. I m using WebClient for this purposes. var uri = new Uri("http://sites.google.com/a/MYDOMAIN.COM/SITENAME/" + "_/rsrc/...

Where do I specify proxy credentials in my WCF client?

I have created a WCF client using channel factory. But I am not able to connect to a server in another machine. I am getting a (407) Prxy Authentication Required exception. WSHttpBinding wsBinding = ...

Detecting login credentials abuse

I am the webmaster for a small, growing industrial association. Soon, I will have to implement a restricted, members-only section for the website. The problem is that our organization membership both ...

热门标签