Export (0) Print
Expand All

ImportCollection Class

Provides a collection of instances of the Import class representing documents to be imported into the XML Web service. This class cannot be inherited.

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

'Declaration
Public NotInheritable Class ImportCollection
	Inherits ServiceDescriptionBaseCollection
'Usage
Dim instance As ImportCollection

public final class ImportCollection extends ServiceDescriptionBaseCollection
public final class ImportCollection extends ServiceDescriptionBaseCollection
Not applicable.

The Import class corresponds to the Web Services Description Language (WSDL) <import> element that is enclosed by the root <definitions> element. For more information about WSDL, see the specification at http://www.w3.org/TR/wsdl/.

The following example demonstrates a typical use of the ImportCollection class.

Imports System
Imports System.Web.Services.Description
Imports System.Xml
Imports Microsoft.VisualBasic

Class ServiceDescription_ImportCollection
   Public Shared Sub Main()
      Dim myServiceDescription As ServiceDescription = _
                              ServiceDescription.Read("StockQuoteService_vb.wsdl")
      Console.WriteLine(" ImportCollection Sample ")
      ' Get Import Collection.
      Dim myImportCollection As ImportCollection = myServiceDescription.Imports
      Console.WriteLine("Total Imports in the document = " + _
                        myServiceDescription.Imports.Count.ToString())
      ' Print 'Import' properties to console.
      Dim i As Integer
      For i = 0 To myImportCollection.Count - 1
         Console.WriteLine(ControlChars.Tab + _
                           "Import Namespace :{0} Import Location :{1} ", _
                           myImportCollection(i).Namespace, _
                           myImportCollection(i).Location)
      Next i

      Dim myImports(myServiceDescription.Imports.Count - 1) As Import
      ' Copy 'ImportCollection' to an array.
      myServiceDescription.Imports.CopyTo(myImports, 0)
      Console.WriteLine("Imports that are copied to Importarray ...")
      Dim j As Integer
      For j = 0 To myImports.Length - 1
         Console.WriteLine(ControlChars.Tab + _
                           "Import Namespace :{0} Import Location :{1} ", _
                           myImports(j).Namespace, myImports(j).Location)
      Next j

      ' Get Import by Index.
      Dim myImport As Import = _
            myServiceDescription.Imports(myServiceDescription.Imports.Count - 1)
      Console.WriteLine("Import by Index...")
      If myImportCollection.Contains(myImport) Then
         Console.WriteLine("Import Namespace '" + myImport.Namespace + _
                           "' is found in 'ImportCollection'.")
         Console.WriteLine("Index of '" + myImport.Namespace + _
                           "' in 'ImportCollection' = " + _
                           myImportCollection.IndexOf(myImport).ToString())
         Console.WriteLine("Delete Import from 'ImportCollection'...")
         myImportCollection.Remove(myImport)
         If myImportCollection.IndexOf(myImport) = - 1 Then
            Console.WriteLine("Import is successfully removed from Import Collection.")
         End If
      End If
   End Sub 'Main
End Class 'ServiceDescription_ImportCollection 

import System.*;
import System.Web.Services.Description.*;
import System.Xml.*;

class ServiceDescriptionImportCollection
{
    public static void main(String[] args)
    {
        ServiceDescription myServiceDescription 
            = ServiceDescription.Read("StockQuoteService_jsl.wsdl");
        Console.WriteLine(" ImportCollection Sample ");

        // Get Import Collection.
        ImportCollection myImportCollection 
            = myServiceDescription.get_Imports();

        Console.WriteLine("Total Imports in the document = " 
            + myServiceDescription.get_Imports().get_Count());

        // Print 'Import' properties to console.
        for (int i = 0; i < myImportCollection.get_Count(); ++i) {
            Console.WriteLine("\tImport Namespace :{0} Import Location :{1} ",
                myImportCollection.get_Item(i).get_Namespace(),
                myImportCollection.get_Item(i).get_Location());
        }

        Import myImports[] = new Import[myServiceDescription.
            get_Imports().get_Count()];

        // Copy 'ImportCollection' to an array.
        myServiceDescription.get_Imports().CopyTo(myImports, 0);
        Console.WriteLine("Imports that are copied to Importarray ...");
        for (int i = 0; i < myImports.length; ++i) {
            Console.WriteLine("\tImport Namespace :{0} Import Location :{1} ",
                myImports[i].get_Namespace(), myImports[i].get_Location());
        }

        // Get Import by Index.
        Import myImport = myServiceDescription.get_Imports().
            get_Item(myServiceDescription.get_Imports().get_Count() - 1);

        Console.WriteLine("Import by Index...");
        if (myImportCollection.Contains(myImport)) {
            Console.WriteLine("Import Namespace '" + myImport.get_Namespace() 
                + "' is found in 'ImportCollection'.");
            Console.WriteLine("Index of '" + myImport.get_Namespace() 
                + "' in 'ImportCollection' = " 
                + myImportCollection.IndexOf(myImport));
            Console.WriteLine("Deleting Import from 'ImportCollection'...");
            myImportCollection.Remove(myImport);
            if (myImportCollection.IndexOf(myImport) == -1) {
                Console.WriteLine(
                    "Import is successfully removed from Import Collection.");
            }
        }
    } //main
} //ServiceDescriptionImportCollection 

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

ADD
Show:
© 2014 Microsoft