ServiceDescription.Imports Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the collection of Import elements contained in the ServiceDescription.

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

public ImportCollection Imports { get; }

Property Value

Type: System.Web.Services.Description.ImportCollection

A collection of import elements contained in the service description.

The ImportCollection returned by this property corresponds to the list of import elements enclosed by the Web Services Description Language (WSDL) definitions root element. For more information about WSDL, see the specification at http://www.w3.org/TR/wsdl/.

ServiceDescription myServiceDescription = new ServiceDescription();
myServiceDescription = 
   ServiceDescription.Read("ServiceDescription_Imports_Input_CS.wsdl");
ImportCollection myImportCollection = myServiceDescription.Imports;

// Create an Import.
Import myImport = new Import();
myImport.Namespace = myServiceDescription.TargetNamespace;

// Set the location for the Import.
myImport.Location = "http://www.contoso.com/";
myImportCollection.Add(myImport);
myServiceDescription.Write("ServiceDescription_Imports_Output_CS.wsdl");
myImportCollection.Clear();
myServiceDescription = 
   ServiceDescription.Read("ServiceDescription_Imports_Output_CS.wsdl");
myImportCollection = myServiceDescription.Imports;
Console.WriteLine(
   "The Import elements added to the ImportCollection are: ");
for(int i = 0; i < myImportCollection.Count; i++)
{
   Console.WriteLine((i+1) + ". " + myImportCollection[i].Location);
}

.NET Framework
Available since 1.1
Return to top
Show: