0

I have written a WCF client which consumes a 3rd party web service.

I used the Visual Studio "Add Service Reference" wizard, and have used the code that it created without a hitch. It is great.

Once I had my client tested on my own development PC and then again on another PC (where internet access is different), I started deploying my WCF client to customers. It is now installed at over 20 sites and working well.

Except: at the latest customer, it will not work because their internet connection is set up to access the internet via a proxy server, and my WCF client fails with status 407.

Now, I know what the proxy server's IP address is, and the user name and password needed to authenticate to it. What I don't know is how I provide those three things to WCF so that it will authenticate with the proxy server for me.

I have tried using

MyWcfClient.ClientCredentials.UserName.UserName = proxyUsername;
MyWcfClient.ClientCredentials.UserName.Password = proxyPassword;

But that doesn't help.

I have searched around various forums for answers to this problem, and have tried some of the suggested solutions, but they seem to revolve around Windows authentication, and seem to be very, very complicated. And my application isn't really all that complicated - as I said above, it works with just the straight code as generated by the VS Service Reference wizard.

How can I specify the proxy's IP address, user name and password so that WCF will authenticate with the proxy for me?

2
Contributors
2
Replies
6
Views
7 Years
Discussion Span
Last Post by PeterTuffin
0

I am experiencing the exact same problem. Has anyone answered this yet, or have you figured out how to get around this?


I have written a WCF client which consumes a 3rd party web service.

I used the Visual Studio "Add Service Reference" wizard, and have used the code that it created without a hitch. It is great.

Once I had my client tested on my own development PC and then again on another PC (where internet access is different), I started deploying my WCF client to customers. It is now installed at over 20 sites and working well.

Except: at the latest customer, it will not work because their internet connection is set up to access the internet via a proxy server, and my WCF client fails with status 407.

Now, I know what the proxy server's IP address is, and the user name and password needed to authenticate to it. What I don't know is how I provide those three things to WCF so that it will authenticate with the proxy server for me.

I have tried using

MyWcfClient.ClientCredentials.UserName.UserName = proxyUsername;
MyWcfClient.ClientCredentials.UserName.Password = proxyPassword;

But that doesn't help.

I have searched around various forums for answers to this problem, and have tried some of the suggested solutions, but they seem to revolve around Windows authentication, and seem to be very, very complicated. And my application isn't really all that complicated - as I said above, it works with just the straight code as generated by the VS Service Reference wizard.

How can I specify the proxy's IP address, user name and password so that WCF will authenticate with the proxy for me?

0

I am experiencing the exact same problem. Has anyone answered this yet, or have you figured out how to get around this?

I should have posted the solution here when I found it, forgive me.
But this is what worked in the end:

BasicHttpBinding binding = new BasicHttpBinding("APISoap"); /* APISoap is the name of the binding element in the app.config */
    binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
    binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic;
    binding.UseDefaultWebProxy = false;
    binding.ProxyAddress = new Uri(string.Format("http://{0}:{1}", proxyIpAddress, proxyPort)); 
    EndpointAddress endpoint = new EndpointAddress("http://www.examplewebservice/api.asmx");

    WebServiceClient client = new WebServiceClient(binding, endpoint);

    client.ClientCredentials.UserName.UserName = proxyUserName;
    client.ClientCredentials.UserName.Password = proxyPassword;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.