Oddur Magnusson

Object reference not set to an instance of a human being

Deploying Web Services, Proxies and GetDefaultProxy()

While deploying our CMS system to one of our clients server we ran into a problem with web service calls and proxies. The client was running its network behind a ISA server and all traffic had to go through the proxy. But when the runtime was making web service calls outside the ISA server (across the INTERNET to a server located at our office) it seems those calls were not being routed through the proxy and were therefore timing out. 

The HttpWebClientProtocol class which our web service class eventually inherits exposes a property named Proxy which accepts a IWebProxy value. The class WebProxy exposes a static method named GetDefaultProxy which return a WebProxy instance with the values defined in Internet Explorer LAN settings. By using this WebProxy instance to the web service class you automatically assign the default values from IE to your web service instance.

Net.Disill.Report.Report reporter = newDisill.Net.Disill.Report.Report();

reporter.Proxy = System.Net.WebProxy.GetDefaultProxy();

From now on I will assign the default proxy to all web service instances I create, since I never know what kind of environment our products gets deployed in. But this method should handle these kind of situations.

Comments

AtliB said:

You can also set this in a configuration file (web.config) which gives you more flexibility

see ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconconfiguringinternetapplications.htm
# February 1, 2004 4:11 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)