searchforsolutions

Just another WordPress.com site

Monthly Archives: June 2012

How to supply dedicated credentials for webproxy authentication in WCF client – Part 2


In my previous blog about the same topic we talked about webproxy authentication in WCF client using configuration file changes.

But the same can be solved programmatically.I’m going to discuss the same here.Its pretty simple & straight forward!

In the code where you initialise you application much before any WCF service calls are made, insert the following piece of code

WebProxy wproxy = new WebProxy(“http://<proxy address>:<proxy port>”, true,null,new NetworkCredential(“<user name>”, “<user password>”,”<domain>”));
WebRequest.DefaultWebProxy = wproxy;

The WCF runtime will acquire proxy setting from WebRequest.DefaultWebProxy property if the <system.net> and WCF <binding> remains useDefaultproxy as “true”.

Then you are done!

Advertisements

How to supply dedicated credentials for webproxy authentication in WCF client – Part 1


This fix assumes you have deployed the application & it is running under the credentials of the user with access to internet.Set the proxy in IE which is the default web proxy or for system web proxy use netsh to setup winhhtp proxy.

<system.serviceModel>
<bindings>
<basicHttpBinding …. useDefaultWebProxy=”Boolean”>
….

<bindings>
</basicHttpBinding>
<system.serviceModel>
<system.net>
<defaultProxy useDefaultCredentials=”true”/>
</system.net>

useDefaultWebProxy:A Boolean value that specifies whether the auto-configured HTTP proxy of the system should be used, if available. The default is true.

The above settings will autheticate the user against the proxy for WCF clients

In my next post we will see how to do it programmatically

Reference :
1. For understanding System.serviceModel configuration refer Ref:http://msdn.microsoft.com/en-us/library/ms731361.aspx
2. For understanding System.net configuration refer refer Ref:http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx. Do read this section if your proxy configuration uses other mechansims like automatic detetcion,script etc.
3. A good short blog on the same topic as above : http://blogs.msdn.com/b/stcheng/archive/2008/12/03/wcf-how-to-supply-dedicated-credentials-for-webproxy-authentication.aspx

Art of story telling

Agile tools- Tracking user stories [ backlogs,user stories]


http://www.userstories.com/products

Comprehensive list of tools for Agile.