title: ServiceDescriptionImporter cannot find definition for web service namespace
body: <p>I'm wondering if anyone knows how to overcome an issue I'm getting when using <code>ServiceDescriptionImporter</code>. I am generating web service client proxy dynamically using CodeDOM, when the web service WSDL has type schema embedded the following code works fine, however when the WSDL contains an import the following code will generate an error on not being able to find the type definition. I did some research on the web and added some code to add the schema to the importer, but I still receive error when creating proxies for WSDLs with import.</p>
  
  <pre class="lang-cs prettyprint-override"><code>Stream stream = client.OpenRead(wsURL);
  
  ServiceDescription description = ServiceDescription.Read(stream);
  
  ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
  
  importer.ProtocolName = "Soap12"; // Use SOAP 1.2.
  
  importer.AddServiceDescription(description, null, null);
  
  // Add any imported files
  foreach (System.Xml.Schema.XmlSchema wsdlSchema in description.Types.Schemas)
  {
      foreach (System.Xml.Schema.XmlSchemaObject externalSchema in wsdlSchema.Includes)
      {
          if (externalSchema is System.Xml.Schema.XmlSchemaImport)
          {
              Uri baseUri = new Uri(wsURL);
              Uri schemaUri = new Uri(baseUri, ((System.Xml.Schema.XmlSchemaExternal)externalSchema).SchemaLocation);
              stream = client.OpenRead(schemaUri);
              System.Xml.Schema.XmlSchema schema = System.Xml.Schema.XmlSchema.Read(stream, null);
              importer.Schemas.Add(schema);
          }
      }
  }
  
  importer.Style = ServiceDescriptionImportStyle.Client;
  
  importer.CodeGenerationOptions = System.Xml.Serialization.CodeGenerationOptions.GenerateProperties;
  
  CodeNamespace nmspace = new CodeNamespace();
  CodeCompileUnit unit1 = new CodeCompileUnit();
  
  unit1.Namespaces.Add(nmspace);
  
  // This is generating the error:
  ServiceDescriptionImportWarnings warning = importer.Import(nmspace, unit1);
  </code></pre>
  
  <p>The error received:</p>
  
  <blockquote>
    <p>Cannot find definition for 'xyz'.  Service Description with namespace 'xyz' is missing.
    Parameter name: name</p>
  </blockquote>
  
  <p>WSDL:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://www.ibm.com/maximo" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.ibm.com/maximo" xmlns:i0="http://www.ibm.com/maximo/wsdl/UWMFO_UWMFO_BB_Interface" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:s="http://www.w3.org/2001/XMLSchema"&gt;
   &lt;wsdl:import location="http://localhost/MaximoWS/MessageService.asmx?wsdl=wsdl1" namespace="http://www.ibm.com/maximo/wsdl/UWMFO_UWMFO_BB_Interface"/&gt;
   &lt;wsdl:types&gt;
    &lt;s:schema targetNamespace="http://www.ibm.com/maximo"&gt;
     &lt;s:include schemaLocation="http://localhost/MaximoWS/MessageService.asmx?schema=schema1"/&gt;
    &lt;/s:schema&gt;
   &lt;/wsdl:types&gt;
   &lt;wsdl:service name="MessageService"&gt;
    &lt;wsdl:port name="UWMFO_UWMFO_BB_InterfaceSOAP12Binding" binding="i0:UWMFO_UWMFO_BB_InterfaceSOAP12Binding"&gt;
     &lt;soap:address location="http://localhost/MaximoWS/MessageService.asmx"/&gt; 
    &lt;/wsdl:port&gt;
    &lt;wsdl:port name="UWMFO_UWMFO_BB_InterfaceSOAP12Binding1" binding="i0:UWMFO_UWMFO_BB_InterfaceSOAP12Binding1"&gt;
     &lt;soap12:address location="http://localhost/MaximoWS/MessageService.asmx"/&gt; 
    &lt;/wsdl:port&gt;
   &lt;/wsdl:service&gt;
  &lt;/wsdl:definitions&gt;
  </code></pre>
  
  <p>Thanks very much</p>