Import Class

Associates an XML namespace with a document location. This class cannot be inherited.

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in

public sealed class Import : DocumentableItem
public final class Import extends DocumentableItem
public final class Import extends DocumentableItem
Not applicable.

The Web Services Description Language (WSDL) import element that is enclosed by the definitions element allows the separation of different parts of the XML Web service into different documents, which can then be imported as required. Each document's URL is associated with a unique XML tag prefix that represents the XML namespace for that document's elements. For more information about WSDL, see the specification at For more information about XML namespaces, see the Namespace property.

The following example shows a user-defined method that creates a new instance of the Import class.

using System;
using System.Web.Services.Description;
using System.Collections;
using System.Xml;

class MySample
   public static void Main()
      Console.WriteLine("Import Sample");
      ServiceDescription myServiceDescription = 
      // Save the ServiceDescripition to an external file.
         "Successfully added import to WSDL document 'StockQuote_cs.wsdl'");

      // Print the import collection to the console.
      myServiceDescription = 
      // Save the ServiceDescripition to an external file.
      Console.WriteLine("Successfully added import to WSDL " +
         "document 'StockQuoteService_cs.wsdl'");

      //Print the import collection to the console.
   // Creates an Import object with namespace and location.
   public static Import CreateImport(string targetNamespace, 
      string targetlocation)
      Import myImport = new Import();
      myImport.Location = targetlocation;
      myImport.Namespace = targetNamespace;
      return myImport;

   public static void PrintImportCollection(string fileName_wsdl)
      // Read import collection properties from generated WSDL file.
      ServiceDescription myServiceDescription1 = 
      ImportCollection myImportCollection = myServiceDescription1.Imports;
      Console.WriteLine("Enumerating Import Collection for file '" + 
         fileName_wsdl +"'...");

      // Print Import properties to console.
      for(int i =0; i < myImportCollection.Count; ++i)
         Console.WriteLine("Namespace : " + myImportCollection[i].Namespace);
         Console.WriteLine("Location  : " + myImportCollection[i].Location);
         Console.WriteLine("ServiceDescription  : " + 

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions