BUG: Compile Error Message When You Add a Web Reference to a Managed Extensions for C++ Application (317807)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2002)
  • Microsoft Visual C++ .NET (2003)

This article was previously published under Q317807

SYMPTOMS

When you add a Web reference to a .NET Web service (.asmx file) in a Managed Extensions for C++ application, you may receive a compile-time error message similar to the following:
Creating web service proxy file...
Error: Cannot find definition for http://test:test. Service Description with namespace http://test is missing.
Parameter name: name
If you would like more help, please type "wsdl /?".
error CS2001: Source file 'Server.cs' could not be found
fatal error CS2008: No inputs specified
The system cannot find the file specified.
You do not experience this behavior when you add the Web reference in a Visual C# .NET application or in a Visual Basic .NET application.

RESOLUTION

To work around this issue, you have to generate the client proxy class (.cs file) that the error message shows as "not found," and then generate an assembly (.dll file) to which you can reference. To do this, follow these steps:
  1. To generate the client proxy class, use the Web Services Description Language tool (Wsdl.exe). Type the following command at a Visual Studio .NET command prompt, and then press ENTER. Verify that you are working in the same directory where the project is located.

    wsdl http://localhost/WeblessService/WeblessService.asmx

  2. The following are two ways to generate an assembly from the client proxy class that you generated previously:
    • Generate an assembly manually by typing the following command at a Visual Studio .NET command prompt. This command generates the Server.dll assembly.

      csc /t:library Server.cs

      -or-
    • Generate the assembly through the add webreference wizard. To do this, follow these steps:
      1. Remove the .wsdl file (for example, Server.wsdl) from the project's Solution Explorer window. This file was added when you tried to add the Web reference earlier. If you do not remove the Server.wsdl file that was created earlier, the wizard will create Server1.wsdl and will look for Server1.cs proxy, and then you will receive an error message again.
      2. Try to add a Web reference from the Solution Explorer. Use the same procedure that you tried earlier. You do not receive an error message this time because you have already generated the client proxy class.
  3. You have to add a reference to use this assembly. To do this, add a reference to the WebService.h header file (add #include "WebService.h" statement in the ProjectName.cpp file) that was generated when you tried to add the Web reference through the wizard. This header file adds a reference to the Server.dll assembly.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

To reproduce the problem, follow these steps:
  1. Create a virual directory named WeblessService, copy the following sample code in the WeblessService.asmx file, and then save the file to a vitual directory:
    <%@WebService language="c#" class="WebService1.Server"%>
    
    namespace WebService1 {
    
        using System;
        using System.Web.Services;
        using System.Web.Services.Protocols;
    
        [WebServiceBinding("test", "http://test", "http://localhost/test.wsdl")]
        public class Server {
    
            public Server() {
            }
    
    	[SoapDocumentMethod(Binding="test")]
            [WebMethod]
            public string HelloWorld() {
                return "Hello World!";
            }
       }
    
    }
    					
  2. Copy the following sample code to Test.wsdl, and then save this file to $\inetpub\wwwroot:
    <?xml version="1.0" encoding="utf-8"?>
    <definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://test" targetNamespace="http://test" xmlns="http://schemas.xmlsoap.org/wsdl/">
      <types>
    <xs:schema xmlns:tns="http://test" elementFormDefault="qualified" targetNamespace="http://test" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="testa">
        <xs:complexType />
      </xs:element>
      <xs:element name="testaResponse">
        <xs:complexType />
      </xs:element>
    </xs:schema>
      </types>
      <message name="testaSoapIn">
        <part name="parameters" element="tns:testa" />
      </message>
      <message name="testaSoapOut">
        <part name="parameters" element="tns:testaResponse" />
      </message>
      <portType name="test">
        <operation name="testa">
          <input message="tns:testaSoapIn" />
          <output message="tns:testaSoapOut" />
        </operation>
      </portType>
      <binding name="test" type="tns:test">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
        <operation name="testa">
          <soap:operation soapAction="http://tempuri.org/testa" style="document" />
          <input>
            <soap:body use="literal" />
          </input>
          <output>
            <soap:body use="literal" />
          </output>
        </operation>
      </binding>
    </definitions>
    
    					
  3. Create the default Managed Extensions for C++ Application.
  4. Add a Web reference by pointing to the asmx that you created in step 1 (http://localhost/WeblessService/WeblessService.asmx ).

REFERENCES

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

310674 HOW TO: Add References to a Managed Visual C++ Project


Modification Type:MajorLast Reviewed:12/6/2003
Keywords:kbbug kbpending KB317807