BUG: "Unable to Import Binding from Namespace" Error Message Occurs When You Try to Create an XML Web Service Proxy File by Using the Web Services Description Language Tool

Article translations Article translations
Article ID: 820122 - View products that this article applies to.
Expand all | Collapse all

On This Page

SYMPTOMS

You may try to use the Web Services Description Language tool (Wsdl.exe) to create an XML Web service proxy file for a Web Services Description Language (WSDL) document. However, if the WSDL document uses a schema that is defined in an external XML Schema (.xsd file) that uses an include element (<include>) to obtain type information, you may receive the following error message:

Error: Unable to import binding 'Service1Soap' from namespace 'http://tempuri.org/'.
- Unable to import operation 'HelloWorld'.
- The element 'http://tempuri.org/XMLSchema.xsd:element1' is missing.

CAUSE

You may receive the error that is mentioned in the "Symptoms" section when Wsdl.exe cannot obtain complete information about an element that is declared in an external XML Schema. Wsdl.exe cannot process include elements (<include>) unless the include elements are contained in a schema element (<schema>) that is contained in the types section (<types>) of a WSDL document. Therefore, when the XML Schema that contains information about an element that is defined in an external XML Schema uses an include element to obtain additional information from the external XML Schema, the problem occurs.

WORKAROUND

To work around this problem, you must modify either the WSDL document or the XML Schemas, or both, so that the XML Schemas do not use include elements. To do this, follow these steps:
  1. Open Service1.wsdl. Paste the following code after the types element (<types>):

    Note This makes sure that you use the include element in Service1.wsdl instead of in an XML Schema.
        <xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified"
          xmlns="http://tempuri.org/XMLSchema.xsd"
          xmlns:xs="http://www.w3.org/2001/XMLSchema">
          <xs:include schemaLocation="XMLSchema2.xsd" />
          <xs:element name="element1" type="MyTyp1"></xs:element>
        </xs:schema>
    Service1.wsdl now contains the following code:
    <?xml version="1.0" encoding="utf-8"?>
    <definitions xmlns:s1="http://tempuri.org/XMLSchema.xsd"
       xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
       xmlns:s="http://www.w3.org/2001/XMLSchema"
       xmlns:s0="http://tempuri.org/"
       xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
       xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
       xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
       targetNamespace="http://tempuri.org/"
       xmlns="http://schemas.xmlsoap.org/wsdl/">
      <types>
        <xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified"
          xmlns="http://tempuri.org/XMLSchema.xsd"
          xmlns:xs="http://www.w3.org/2001/XMLSchema">
          <xs:include schemaLocation="XMLSchema2.xsd" />
          <xs:element name="element1" type="MyTyp1"></xs:element>
        </xs:schema>
        <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
          <s:import namespace="http://tempuri.org/XMLSchema.xsd" />
          <s:element name="HelloWorld">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" ref="s1:element1" />
              </s:sequence>
            </s:complexType>
          </s:element>
          <s:element name="HelloWorldResponse">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult" type="s:string" />
              </s:sequence>
            </s:complexType>
          </s:element>
        </s:schema>
      </types>
      <message name="HelloWorldSoapIn">
        <part name="parameters" element="s0:HelloWorld" />
      </message>
      <message name="HelloWorldSoapOut">
        <part name="parameters" element="s0:HelloWorldResponse" />
      </message>
      <portType name="Service1Soap">
        <operation name="HelloWorld">
          <input message="s0:HelloWorldSoapIn" />
          <output message="s0:HelloWorldSoapOut" />
        </operation>
      </portType>
      <portType name="Service1HttpGet" />
      <portType name="Service1HttpPost" />
      <binding name="Service1Soap" type="s0:Service1Soap">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
        <operation name="HelloWorld">
          <soap:operation soapAction="http://tempuri.org/HelloWorld" style="document" />
          <input>
            <soap:body use="literal" />
          </input>
          <output>
            <soap:body use="literal" />
          </output>
        </operation>
      </binding>
      <binding name="Service1HttpGet" type="s0:Service1HttpGet">
        <http:binding verb="GET" />
      </binding>
      <binding name="Service1HttpPost" type="s0:Service1HttpPost">
        <http:binding verb="POST" />
      </binding>
      <service name="Service1">
        <port name="Service1Soap" binding="s0:Service1Soap">
          <soap:address location="http://localhost/820122/New3/WebService1/Service1.asmx" />
        </port>
        <port name="Service1HttpGet" binding="s0:Service1HttpGet">
          <http:address location="http://localhost/820122/New3/WebService1/Service1.asmx" />
        </port>
        <port name="Service1HttpPost" binding="s0:Service1HttpPost">
          <http:address location="http://localhost/820122/New3/WebService1/Service1.asmx" />
        </port>
      </service>
    </definitions>
  2. Move to the Visual Studio .NET command prompt. Change to the directory path of Service1.wsdl.
  3. Run the following command from the command prompt:

    wsdl Service1.wsdl

    Note In this case, you do not have to provide Wsdl.exe with XMLSchema1.xsd as a command-line parameter. You already use the include element in Service1.wsdl.

    You may receive a message that is similar to the following:

    Writing file '%File Path%\Service1.cs'.


    %File Path% is a placeholder for the location of Service1.wsdl.

    Also, an XML Web service proxy file that is named Service1.cs is created.
Note These steps are based on the sample from the "More Information" section of this article. Therefore, the code and the file names in these steps may differ from your code and your file names.

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 Problem

  1. Start Notepad, and then paste the following WSDL code in Notepad:
    <?xml version="1.0" encoding="utf-8"?>
    <definitions xmlns:s1="http://tempuri.org/XMLSchema.xsd"
       xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
       xmlns:s="http://www.w3.org/2001/XMLSchema"
       xmlns:s0="http://tempuri.org/"
       xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
       xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
       xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
       targetNamespace="http://tempuri.org/"
       xmlns="http://schemas.xmlsoap.org/wsdl/">
      <types>
        <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
          <s:import namespace="http://tempuri.org/XMLSchema.xsd" />
          <s:element name="HelloWorld">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" ref="s1:element1" />
              </s:sequence>
            </s:complexType>
          </s:element>
          <s:element name="HelloWorldResponse">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult" type="s:string" />
              </s:sequence>
            </s:complexType>
          </s:element>
        </s:schema>
      </types>
      <message name="HelloWorldSoapIn">
        <part name="parameters" element="s0:HelloWorld" />
      </message>
      <message name="HelloWorldSoapOut">
        <part name="parameters" element="s0:HelloWorldResponse" />
      </message>
      <portType name="Service1Soap">
        <operation name="HelloWorld">
          <input message="s0:HelloWorldSoapIn" />
          <output message="s0:HelloWorldSoapOut" />
        </operation>
      </portType>
      <portType name="Service1HttpGet" />
      <portType name="Service1HttpPost" />
      <binding name="Service1Soap" type="s0:Service1Soap">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
        <operation name="HelloWorld">
          <soap:operation soapAction="http://tempuri.org/HelloWorld" style="document" />
          <input>
            <soap:body use="literal" />
          </input>
          <output>
            <soap:body use="literal" />
          </output>
        </operation>
      </binding>
      <binding name="Service1HttpGet" type="s0:Service1HttpGet">
        <http:binding verb="GET" />
      </binding>
      <binding name="Service1HttpPost" type="s0:Service1HttpPost">
        <http:binding verb="POST" />
      </binding>
      <service name="Service1">
        <port name="Service1Soap" binding="s0:Service1Soap">
          <soap:address location="http://localhost/820122/New3/WebService1/Service1.asmx" />
        </port>
        <port name="Service1HttpGet" binding="s0:Service1HttpGet">
          <http:address location="http://localhost/820122/New3/WebService1/Service1.asmx" />
        </port>
        <port name="Service1HttpPost" binding="s0:Service1HttpPost">
          <http:address location="http://localhost/820122/New3/WebService1/Service1.asmx" />
        </port>
      </service>
    </definitions>
  2. Save the document as Service1.wsdl.
  3. Open Notepad, and then paste the following code in Notepad:
    <?xml version="1.0" encoding="utf-8" ?>
    <xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified"
       xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
       <xs:include schemaLocation="XMLSchema2.xsd" />
       <xs:element name="element1" type="MyTyp1"></xs:element>
    </xs:schema>
  4. Save the document as XMLSchema1.xsd in the same folder where you created Service1.wsdl in step 2.
  5. Paste the following code in Notepad:
    <?xml version="1.0" encoding="utf-8" ?>
    <xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified"
       xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
       <xs:complexType name="MyTyp1">
          <xs:sequence>
             <xs:element name="element1" type="xs:string" />
             <xs:element name="element2" type="xs:int" />
          </xs:sequence>
       </xs:complexType>
    </xs:schema>
  6. Save the document as XMLSchema2.xsd in the same folder where you created Service1.wsdl in step 2.
  7. Move to the Visual Studio .NET command prompt. Change to the directory path of Service1.wsdl.
  8. Run the following command from the command prompt:

    wsdl Service1.wsdl XMLSchema1.xsd

    You receive the error in the "Symptoms" section of this article.

REFERENCES

For more information about creating an XML Web service proxy, the Web Services Description Language tool (Wsdl.exe), and XML Schemas, visit the following Microsoft Web sites:

http://msdn2.microsoft.com/en-us/library/d2s8y7bs(vs.71).aspx

http://msdn2.microsoft.com/en-us/library/7h3ystb6(vs.71).aspx



For more information about Web Services Description Language (WSDL) 1.1, visit the following W3C Web site:

http://www.w3.org/TR/wsdl

Properties

Article ID: 820122 - Last Review: May 24, 2007 - Revision: 3.4
APPLIES TO
  • Microsoft Web Services Enhancements for Microsoft .NET 1.1
  • Microsoft Web Services (included with the .NET Framework) 1.0
Keywords: 
kbclient kbproxydev kbmisctools kbcodegen kbxml kbschema kbcommandline kbwebservices kbcompiler kberrmsg kbbug KB820122
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com