BUG: Error Occurs When You Try to Add a Web Reference to a Web Service That a Proxy Server Publishes

Symptoms

In an ASP.NET Web Application project, when you try to add a Web reference to a Web service that a proxy server publishes, you may receive an error message that is similar to the following error message.

Microsoft .NET Framework 1.0
Unable to download the following files from http://<wsproxyserver>/WebService2/service1.asmx?op=HelloWorld, http://<wsproxyserver>:6789/WebService2/service1.asmx?wsdl. Do you want to skip these files and continue?
Microsoft .NET Framework 1.1
Unable to download the following file from http://<wsproxyserver>:6789/WebService2/service1.asmx?wsdl. Do you want to skip this file and continue?
Note Throughout this article, wsproxyserver is a placeholder for the IP address of the proxy server.

Cause

From a Web client, you try to add a Web reference to a Web service so that the internal Web server is inside a proxy network. The Redirect port number of the proxy server is then attached to the Internet Protocol (IP) address of the proxy server in the generated proxy class instead of the Listener port number of the proxy server being attached to the IP address of the proxy server in the generated proxy class.

Workaround

To work around this bug, use the Web Services Description Language tool (Wsdl.exe) to create a client proxy class and then modify the proxy class to update the URL information with the correct port number.

To do this, follow these steps:
  1. Create a client proxy class.

    To do this, follow these steps:
    1. In Microsoft Windows Explorer, create a folder that is named
      Clientproxy in the C:\ root directory.
    2. At a Microsoft Visual Studio .NET command prompt, change the directory path to the C:\Clientproxy directory.
    3. At the Visual Studio .NET command prompt, run the following command.

      Microsoft Visual C# .NET
      wsdl http://wsproxyserver/WebServiceProxy/Service1.asmx?wsdl
      The client proxy class is saved as the Service1.cs file.

      Microsoft Visual Basic .NET
      wsdl /l:VB http://wsproxyserver/WebServiceProxy/Service1.asmx?wsdl
      The client proxy class is saved as the Service1.vb file.
  2. Modify the client proxy class.

    To do this, follow these steps:
    1. Use Notepad to open the Service1.cs file or to open the Service1.vb file.

      The proxy URL contains the port number (6789) of the internal Web server as follows:
      http://<wsproxyserver>:6789/WebServiceProxy/service1.asmx
    2. In Visual C# .NET, modify the
      Service1 method of the proxy class, and then save the
      Service1 method of the proxy class, as follows:
      public Service1()
      {
      this.Url = "http://<wsproxyserver>/WebServiceProxy/service1.asmx";
      }
      In Visual Basic .NET, modify the New method of the proxy class, and then save the New method of the proxy class, as follows:
      Public Sub New()
      MyBase.New
      Me.Url = "http://<wsproxyserver>/WebServiceProxy/service1.asmx"
      End Sub
  3. Compile the proxy class code that is stored in the Service1.cs file or in the Service1.vb file to create the Service1.dll assembly.

    To do this, follow these steps:
    1. At a Visual Studio .NET command prompt, change the directory path to the C:\Clientproxy directory.
    2. At the Visual Studio .NET command prompt, run the following command:

      Visual C# .NET
      csc /t:library Service1.cs
      Visual Basic .NET
      vbc /t:library /r:System.XML.dll,System.Web.Services.dll,System.Data.dll,System.Web.dll,System.dll Service1.vb
      The Service1.dll file is created.
  4. Create an ASP.NET Web Application project.

    To do this, follow these steps:
    1. Start Visual Studio .NET.
    2. Use Visual C# .NET or use Visual Basic .NET to create an ASP.NET Web Application project that is named
      Project1.
    3. In Solution Explorer, right-click Project1, and then click Add Reference.
    4. In the Add Reference dialog box, click
      Browse.
    5. In the Select Component dialog box, locate the C:\Clientproxy folder.
    6. Click Service1.dll, and then click
      Open.
    7. Click OK to close the Add Reference dialog box.

Status

This behavior is by design.

More Information

Required Proxy Server Settings

Publishing Rules of the ISA Server When It Is Installed on a Proxy Server

Set the publishing rule for the ISA server to redirect all the incoming requests to the internal Web server. The Listener listens on port 80 and then redirects all the incoming requests to port 6789.

Note You can configure your proxy server to redirect incoming requests to any port other than port 6789.

Web Site Configuration on the Internal Web Server

Configure the default Web site to run on port 6789 on the internal Web server.

Steps to Reproduce the Behavior

Create an ASP.NET Web Service Project on a Computer (Internal Web Server) That Is Inside a Proxy Network

  1. Start Visual Studio .NET.
  2. Use Visual C# .NET or use Visual Basic .NET to create an ASP.NET Web Service project that is named
    WebServiceProxy.

    By default, the Service1.asmx file is created.
  3. In Solution Explorer, right-click
    Service1.asmx, and then click View Code.
  4. Uncomment the HelloWorld Web service method.
  5. On the Build menu, click Build Solution.
  6. Configure the default Web site to run on port 6789.


    To do this, follow these steps:
    1. Click Start, and then click
      Run.

      The Run dialog box is displayed.
    2. Type
      Inetmgr in the Open box, and then click OK.
    3. In the Internet Information Services Manager window, click your Computer Name.
    4. Click the Web Sites folder.
    5. Under the Web Sites folder, right-click the
      Default Web Site folder. Click
      Properties.
    6. On the
      Default Web Site Properties dialog box, click the Web Site tab.
    7. In the TCP port text box, type
      6789.
    8. Click OK to close the Default Web Site Properties dialog box.
  7. To verify that the WebServiceProxy Web service is working correctly, use your Web browser to visit the following URL:
    http://internalwebserver:6789/WebServiceProxy/Service1.asmx
    Note In this URL, internalwebserver is a placeholder for the name of your internal Web server.

Create an ASP.NET Web Application Project on a Computer That Is Outside the Proxy Server

  1. Start Visual Studio .NET.
  2. Use Visual C# .NET or use Visual Basic .NET to create an ASP.NET Web Application project that is named
    Project1.
  3. On the Build menu, click Build Solution.

Add a Web Reference to the Web Service

  1. In Solution Explorer, right-click
    References, and then click Add Web Reference.


    The Add Web Reference dialog box is displayed.
  2. Type
    http://wsproxyserver/WebServiceProxy/Service1.asmxin the Address box, and then click
    Go.
  3. When the proxy server prompts you for authentication credentials, type your UserNameand type your Password in the corresponding text boxes.

    You receive the error message that is mentioned in the "Symptoms" section of this article.

    Note If the IP address in the error message contains the port number of the internal Web server, configure the publishing properties of the ISA server to display the IP address of the proxy server instead of displaying the IP address of the internal Web server.

References

For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
308359 HOW TO: Write a Simple Web Service by Using Visual C# .NET

313072 HOW TO: Configure the Web Publishing Service to Work with Internet Security and Acceleration Server in Windows 2000

Propriedades

ID do Artigo: 815213 - Última Revisão: 24 de mar de 2009 - Revisão: 1

Comentários