Microsoft KB Archive/820122

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

Article ID: 820122

Article Last Modified on 5/24/2007

-

APPLIES TO


 * Microsoft Web Services Enhancements for Microsoft .NET 1.1
 * Microsoft Web Services Enhancements for Microsoft .NET 2.0

-





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 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 &quot;Symptoms&quot; 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 unless the include elements are contained in a schema element  that is contained in the types section  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:   Open Service1.wsdl. Paste the following code after the types element :

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

is a placeholder for the location of Service1.wsdl.

Also, an XML Web service proxy file that is named Service1.cs is created.</li></ol>

Note These steps are based on the sample from the &quot;More Information&quot; section of this article. Therefore, the code and the file names in these steps may differ from your code and your file names.

<div class="status_section">

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

<div class="moreinformation_section">

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

wsdl Service1.wsdl XMLSchema1.xsd

You receive the error in the &quot;Symptoms&quot; section of this article.</li></ol>

<div class="references_section">