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.
Assembly: System.Web.Services (in System.Web.Services.dll)
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.
#using <System.dll> #using <System.Web.Services.dll> #using <System.Xml.dll> using namespace System; using namespace System::Web::Services::Description; using namespace System::Xml; int main() { ServiceDescription^ myServiceDescription = ServiceDescription::Read( "StockQuoteService_cpp.wsdl" ); Console::WriteLine( " ImportCollection Sample " ); // Get Import Collection. ImportCollection^ myImportCollection = myServiceDescription->Imports; Console::WriteLine( "Total Imports in the document = {0}", myServiceDescription->Imports->Count ); // Print 'Import' properties to console. for ( int i = 0; i < myImportCollection->Count; ++i ) Console::WriteLine( "\tImport Namespace : {0} Import Location : {1} ", myImportCollection[ i ]->Namespace, myImportCollection[ i ]->Location ); array<Import^>^myImports = gcnew array<Import^>(myServiceDescription->Imports->Count); // Copy 'ImportCollection' to an array. myServiceDescription->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 ]->Namespace, myImports[ i ]->Location ); // Get Import by Index. Import^ myImport = myServiceDescription->Imports[ myServiceDescription->Imports->Count - 1 ]; Console::WriteLine( "Import by Index..." ); if ( myImportCollection->Contains( myImport ) ) { Console::WriteLine( "Import Namespace ' {0} ' is found in 'ImportCollection'.", myImport->Namespace ); Console::WriteLine( "Index of '{0}' in 'ImportCollection' = {1}", myImport->Namespace, 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." ); } }
#using <mscorlib.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Xml;
int main()
{
ServiceDescription * myServiceDescription = ServiceDescription::Read(S"StockQuoteService_cs.wsdl");
Console::WriteLine(S" ImportCollection Sample ");
// Get Import Collection.
ImportCollection * myImportCollection = myServiceDescription->Imports;
Console::WriteLine(S"Total Imports in the document = {0}", __box(myServiceDescription -> Imports->Count));
// Print 'Import' properties to console.
for (int i = 0; i < myImportCollection->Count; ++i)
Console::WriteLine(S"\tImport Namespace : {0} Import Location : {1} "
, myImportCollection->Item[i]->Namespace
, myImportCollection->Item[i]->Location);
Import* myImports[] = new Import*[myServiceDescription->Imports->Count];
// Copy 'ImportCollection' to an array.
myServiceDescription->Imports->CopyTo(myImports, 0);
Console::WriteLine(S"Imports that are copied to Importarray ...");
for (int i=0;i < myImports->Length; ++i)
Console::WriteLine(S"\tImport Namespace : {0} Import Location : {1} ",
myImports[i]->Namespace,
myImports[i]->Location
);
// Get Import by Index.
Import * myImport = myServiceDescription->Imports->Item[myServiceDescription->Imports->Count-1];
Console::WriteLine(S"Import by Index...");
if (myImportCollection->Contains(myImport))
{
Console::WriteLine(S"Import Namespace ' {0} ' is found in 'ImportCollection'.", myImport -> Namespace);
Console::WriteLine(S"Index of '{0}' in 'ImportCollection' = {1}", myImport -> Namespace, __box(myImportCollection->IndexOf(myImport)));
Console::WriteLine(S"Deleting Import from 'ImportCollection'...");
myImportCollection->Remove(myImport);
if (myImportCollection->IndexOf(myImport) == -1)
Console::WriteLine(S"Import is successfully removed from Import Collection.");
}
}
System.Collections::CollectionBase
System.Web.Services.Description::ServiceDescriptionBaseCollection
System.Web.Services.Description::ImportCollection
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.