This documentation is archived and is not being maintained.

ServiceDescription.Imports Property

Gets the collection of Import elements contained in the ServiceDescription.

[Visual Basic]
Public ReadOnly Property Imports As ImportCollection
[C#]
public ImportCollection Imports {get;}
[C++]
public: __property ImportCollection* get_Imports();
[JScript]
public function get Imports() : ImportCollection;

Property Value

An ImportCollection.

Remarks

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/.

Example

[Visual Basic] 
Dim myServiceDescription As New ServiceDescription()
myServiceDescription = _
   ServiceDescription.Read("ServiceDescription_Imports_Input_VB.wsdl")
Dim myImportCollection As ImportCollection = myServiceDescription.Imports

' Create an Import.
Dim myImport As 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_VB.wsdl")
myImportCollection.Clear()
myServiceDescription = _
   ServiceDescription.Read("ServiceDescription_Imports_Output_VB.wsdl")
myImportCollection = myServiceDescription.Imports
Console.WriteLine( _
   "The Import elements added to the ImportCollection are: ")
Dim i As Integer
For i = 0 To myImportCollection.Count - 1
   Console.WriteLine((i + 1).ToString() & ". " & _
      myImportCollection(i).Location)
Next i

[C#] 
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);
}

[C++] 
ServiceDescription* myServiceDescription = new ServiceDescription();
myServiceDescription = 
   ServiceDescription::Read(S"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 = S"http://www.contoso.com/";
myImportCollection->Add(myImport);
myServiceDescription->Write(S"ServiceDescription_Imports_Output_CS.wsdl");
myImportCollection->Clear();
myServiceDescription = 
   ServiceDescription::Read(S"ServiceDescription_Imports_Output_CS.wsdl");
myImportCollection = myServiceDescription->Imports;
Console::WriteLine(
   S"The Import elements added to the ImportCollection are: ");
for(int i = 0; i < myImportCollection->Count; i++)
{
   Console::WriteLine(S"{0}. {1}", __box((i+1)), myImportCollection->Item[i]->Location);
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

ServiceDescription Class | ServiceDescription Members | System.Web.Services.Description Namespace

Show: