Import Class
Assembly: System.Web.Services (in system.web.services.dll)
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.dll> #using <System.Xml.dll> #using <System.Web.Services.dll> using namespace System; using namespace System::Web::Services::Description; using namespace System::Collections; using namespace System::Xml; // Creates an Import object with namespace and location. Import^ CreateImport( String^ targetNamespace, String^ targetlocation ) { Import^ myImport = gcnew Import; myImport->Location = targetlocation; myImport->Namespace = targetNamespace; return myImport; } void PrintImportCollection( String^ fileName_wsdl ) { // Read import collection properties from generated WSDL file. ServiceDescription^ myServiceDescription1 = ServiceDescription::Read( fileName_wsdl ); ImportCollection^ myImportCollection = myServiceDescription1->Imports; Console::WriteLine( "Enumerating Import Collection for file ' {0}'...", fileName_wsdl ); // Print Import properties to console. for ( int i = 0; i < myImportCollection->Count; ++i ) { Console::WriteLine( "Namespace : {0}", myImportCollection[ i ]->Namespace ); Console::WriteLine( "Location : {0}", myImportCollection[ i ]->Location ); Console::WriteLine( "ServiceDescription : {0}", myImportCollection[ i ]->ServiceDescription->Name ); } } int main() { Console::WriteLine( "Import Sample" ); ServiceDescription^ myServiceDescription = ServiceDescription::Read( "StockQuote_cpp.wsdl" ); myServiceDescription->Imports->Add( CreateImport( "http://localhost/stockquote/schemas", "http://localhost/stockquote/stockquote_cpp.xsd" ) ); // Save the ServiceDescripition to an external file. myServiceDescription->Write( "StockQuote_cpp.wsdl" ); Console::WriteLine( "document 'StockQuote_cpp.wsdl'" ); // Print the import collection to the console. PrintImportCollection( "StockQuote_cpp.wsdl" ); myServiceDescription = ServiceDescription::Read( "StockQuoteService_cpp.wsdl" ); myServiceDescription->Imports->Insert( 0, CreateImport( "http://localhost/stockquote/definitions", "http://localhost/stockquote/stockquote_cpp.wsdl" ) ); // Save the ServiceDescripition to an external file. myServiceDescription->Write( "StockQuoteService_cs::wsdl" ); Console::WriteLine( "" ); Console::WriteLine( "document 'StockQuoteService_cpp.wsdl'" ); //Print the import collection to the console. PrintImportCollection( "StockQuoteService_cpp.wsdl" ); }
System.Web.Services.Description.DocumentableItem
System.Web.Services.Description.Import
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.