HOW TO: Configure an XML Web Service Client by Using the .NET Framework to Work with a Proxy Server (307220)



The information in this article applies to:

  • Microsoft Web Services (included with the .NET Framework) 1.0
  • Microsoft Proxy Server 2.0

This article was previously published under Q307220

SUMMARY

This step-by-step article describes how to allow an XML Web service client application that is built with the .NET runtime to connect to a service through a Hypertext Transfer Protocol (HTTP) proxy server.

back to the top

Requirements

The following items describe the recommended hardware, software, network infrastructure, skills and knowledge, and service packs that you need:
  • XML
  • HTTP proxy concepts
back to the top

Configure the HTTP Proxy Settings for Desktop and ASP.NET Applications

Generally, the .NET runtime uses the default proxy settings that have been set for Microsoft Internet Explorer when it is used from a standard desktop application. If you can browse to the Web site where your Web service is located, you can make calls with the .NET runtime without making a change because your settings are retrieved from where they are stored in your user profile.

The .NET runtime does not, however, support automatic proxy discovery scripts. If Internet Explorer uses the automatic configuration options to determine the HTTP proxy settings, you can manually configure the global HTTP proxy settings in the Machine.config file. Likewise, if you are using the .NET runtime to access an XML Web service in a situation in which a user profile is not loaded (for example, if you call an XML Web service from an ASP.NET page), you must configure the computer settings in the Machine.config file.

To configure the HTTP proxy settings for desktop and ASP.NET applications, follow these steps:
  1. Edit the Machine.config file. For the .NET Framework, the default location for this file is C:\WINNT\Microsoft .NET\Framework\v1.0.2914\CONFIG\machine.config.
  2. Locate the \configuration\system.net\defaultProxy element in the XML.
  3. Change the child <proxy> element to the following, where http://myproxyserver indicates your HTTP proxy server:
    <proxy usesystemdefault="false" 
           proxyaddress="http://myproxyserver" 
           bypassonlocal="true" /> 
    						
    The bypassonlocal attribute indicates that requests to hosts whose names contain a period (.) should not be sent through the proxy.
  4. If other addresses need to bypass the proxy server, you can add them by creating a <bypasslist> element as a child of the <defaultProxy> element. The <bypasslist> syntax should resemble the following:
    <bypasslist>
        <add address="localdomain.com|localdomain2.com" />
    </bypasslist> 
    						
    This syntax avoids sending any requests to localdomain.com and localdomain2.com through the HTTP proxy. The address attribute is actually a string that contains a regular expression. For more information on the syntax of regular expressions, see the information on System.Text.RegularExpresions in the .NET runtime documentation.
  5. Save the changes to Machine.config and restart the application.
back to the top

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

318140 PRB: Error .NET Client that Consumes Web Svc Through HTTP


Modification Type:MajorLast Reviewed:7/31/2003
Keywords:kbHOWTOmaster KB307220 kbAudDeveloper