PRB: Error on .NET client that consumes a Web service through an HTTP proxy server (318140)
The information in this article applies to:
- Microsoft .NET Framework 1.0
- Microsoft .NET Framework 1.1
- Microsoft ASP.NET (included with the .NET Framework) 1.0
- Microsoft ASP.NET (included with the .NET Framework 1.1)
This article was previously published under Q318140 SYMPTOMSNote The following .NET Framework Class Library namespace is
referenced in this article: System.Net When you use a .NET
client to consume a Web service through an HTTP proxy server, you may receive
the following error message: The underlying connection
was closed: The remote name could not be resolved. CAUSE An HTTP proxy server exists between the Web service and the
.NET client, and the proper proxy settings have not been configured.RESOLUTION To resolve this problem, supply the proper proxy
configuration settings to the .NET client. MORE INFORMATION The following are the default settings in the
Machine.config file:
<configuration>
<system.net>
<defaultProxy>
<proxy
usesystemdefault = "true"
/>
</defaultProxy>
</system.net>
</configuration>
If the default settings do not automatically detect the proxy server
settings, set usessystemdefault to false, and then explicitly designate the proxy server. To
designate the proxy server explicitly, use either the Machine.config or
Web.config file, or specify the server programmatically. To specify
the proxy server, set the Machine.config or Web.config file settings as
follows:
<configuration>
<system.net>
<defaultProxy>
<proxy
usesystemdefault = "false"
proxyaddress="http://proxyserver"
bypassonlocal="true"
/>
</defaultProxy>
</system.net>
</configuration>
To change the settings programmatically by using a WebProxy object, use the following sample code:
Using System.Net;
com.someserver.somewebservice.someclass MyWebServiceClass = new com.someserver.somewebservice.someclass();
IWebProxy proxyObject = new WebProxy("http://myproxyserver:80", true);
MyWebServiceClass.Proxy = proxyObject;
MyWebServiceClass.MyWebMethod();
Proxy servers that require NTLM authentication To set NTML authentication for the proxy server, use the following sample code:
Using System.Net;
WebProxy myProxy = new WebProxy("http://proxyserver:port",true);
myProxy.Credentials = CredentialCache.DefaultCredentials;
FindServiceSoap myFindService = new FindServiceSoap();
myFindService.Proxy = myProxy; You can also use system-wide proxy as default. To do this, use the following settings in the configuration file:
<configuration>
<system.net>
<defaultProxy>
<proxy
proxyaddress = "http://proxyserver:80"
bypassonlocal = "true" />
</defaultProxy>
</system.net>
</configuration> REFERENCES For more information, see the following Microsoft Developer
Network (MSDN) Web sites:
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
307220
How to configure an XML Web service client by using the .NET Framework to work with a proxy server
Modification Type: | Major | Last Reviewed: | 7/2/2004 |
---|
Keywords: | kbprb KB318140 |
---|
|