Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Import Class
Collapse the table of content
Expand the table of content

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 System.Web.Services.dll)

public sealed class Import : DocumentableItem

The Import type exposes the following members.

Public methodImportInitializes a new instance of the Import class.

Public propertyDocumentationGets or sets the text documentation for the instance of the DocumentableItem. (Inherited from DocumentableItem.)
Public propertyDocumentationElementGets or sets the documentation element for the DocumentableItem. (Inherited from DocumentableItem.)
Public propertyExtensibleAttributesGets or sets an array of type XmlAttribute that represents attribute extensions of WSDL to comply with Web Services Interoperability (WS-I) Basic Profile 1.1. (Inherited from DocumentableItem.)
Public propertyExtensionsGets the ServiceDescriptionFormatExtensionCollection associated with this Import class. (Overrides DocumentableItem.Extensions.)
Public propertyLocationGets or sets the value of the XML location attribute of the import element.
Public propertyNamespaceGets or sets the value of the XML namespace attribute of the import element.
Public propertyNamespacesGets or sets the dictionary of namespace prefixes and namespaces used to preserve namespace prefixes and namespaces when a ServiceDescription object is constructed. (Inherited from DocumentableItem.)
Public propertyServiceDescriptionGets a reference to the ServiceDescription of which the Import is a member.

Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

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 http://www.w3.org/TR/wsdl/. 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  : " + 

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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