Michael Falconer

the difficult takes time, the impossible just a little longer

My Links

Blog Stats

News

Michael Falconer is a freelance/contract .net developer working in and around Glasgow, Scotland, mainly on asp.net applications. His company is called, for some strange reason, Camel-Jones.

Archives

Post Categories

Blogs

Other Links

Regulars

Accessing web services through a proxy / firewall

One of the projects I'm involved in at the moment has me developing some client applications (both web and windows based) that access a web service. I was just preparing an initial release when, during testing, I found that the Windows application could not always access the web service as the user had to access the internet via a proxy server. After a quick read of this article on CodeProject and this posting on .NET 247, I simply added the following code to always call the web service with the users IE proxy settings:

If Not WebProxy.GetDefaultProxy.IsBypassed(New Uri(myWS.Url)) Then
    Dim myProxy As WebProxy = WebProxy.GetDefaultProxy
    myProxy.Credentials = CredentialCache.DefaultCredentials
    myWS.Proxy = myProxy
End If

myWS is the web service whose proxy settings you need to set. Hopefully somebody might find it useful!

posted on Friday, July 02, 2004 2:00 PM