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 (820122)
The information in this article applies to:
- Microsoft Web Services (included with the .NET Framework 1.1)
- Microsoft Web Services (included with the .NET Framework) 1.0
SYMPTOMSYou 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. CAUSEYou 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.WORKAROUNDTo 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 (<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> - Move to the Visual Studio .NET command prompt. Change to the
directory path of Service1.wsdl.
- 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.
Modification Type: | Major | Last Reviewed: | 6/26/2003 |
---|
Keywords: | kbClient kbProxyDev kbMiscTools kbCodeGen kbXML kbSchema kbCommandLine kbWebServices kbCompiler kberrmsg kbBug KB820122 kbAudDeveloper |
---|
|