This documentation is archived and is not being maintained.
PortTypeCollection Class
Visual Studio 2008
Represents a collection of instances of the PortType class; that is, a collection of sets of operations supported by the XML Web service. This class cannot be inherited.
Assembly: System.Web.Services (in System.Web.Services.dll)
#using <System.Xml.dll> #using <System.Web.Services.dll> #using <System.dll> using namespace System; using namespace System::Web::Services::Description; using namespace System::Xml; using namespace System::Collections; int main() { try { // Read the existing Web service description file. ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_CS.wsdl" ); PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; int noOfPortTypes = myServiceDescription->PortTypes->Count; Console::WriteLine( "\nTotal number of PortTypes: {0}", myServiceDescription->PortTypes->Count ); // Get the first PortType in the collection. PortType^ myNewPortType = myPortTypeCollection[ "MathServiceSoap" ]; int index = myPortTypeCollection->IndexOf( myNewPortType ); Console::WriteLine( "The PortType with the name {0} is at index: {1}", myNewPortType->Name, (index + 1) ); Console::WriteLine( "Removing the PortType: {0}", myNewPortType->Name ); // Remove the PortType from the collection. myPortTypeCollection->Remove( myNewPortType ); bool bContains = myPortTypeCollection->Contains( myNewPortType ); Console::WriteLine( "The PortType with the name {0} exists: {1}", myNewPortType->Name, bContains ); Console::WriteLine( "Total number of PortTypes after removing: {0}", myServiceDescription->PortTypes->Count ); Console::WriteLine( "Adding a PortType: {0}", myNewPortType->Name ); // Add a new portType from the collection. myPortTypeCollection->Add( myNewPortType ); // Display the number of portTypes after adding a port. Console::WriteLine( "Total number of PortTypes after adding a new port: {0}", myServiceDescription->PortTypes->Count ); // List the PortTypes available in the WSDL document. IEnumerator^ myEnum = myPortTypeCollection->GetEnumerator(); while ( myEnum->MoveNext() ) { PortType^ myPortType = safe_cast<PortType^>(myEnum->Current); Console::WriteLine( "The PortType name is: {0}", myPortType->Name ); } myServiceDescription->Write( "MathService_New.wsdl" ); } catch ( Exception^ e ) { Console::WriteLine( "Exception: {0}", e->Message ); } }
#using <mscorlib.dll>
#using <System.Xml.dll>
#using <System.Web.Services.dll>
#using <System.dll>
using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Xml;
using namespace System::Collections;
int main()
{
try
{
// Read the existing Web service description file.
ServiceDescription* myServiceDescription =
ServiceDescription::Read(S"MathService_CS.wsdl");
PortTypeCollection* myPortTypeCollection =
myServiceDescription->PortTypes;
int noOfPortTypes = myServiceDescription->PortTypes->Count;
Console::WriteLine(S"\nTotal number of PortTypes: {0}",
__box(myServiceDescription->PortTypes->Count));
// Get the first PortType in the collection.
PortType* myNewPortType = myPortTypeCollection->Item[S"MathServiceSoap"];
int index = myPortTypeCollection->IndexOf(myNewPortType);
Console::WriteLine(S"The PortType with the name {0} is at index: {1}",
myNewPortType->Name, __box((index+1)));
Console::WriteLine(S"Removing the PortType: {0}", myNewPortType->Name);
// Remove the PortType from the collection.
myPortTypeCollection->Remove(myNewPortType);
bool bContains = myPortTypeCollection->Contains(myNewPortType);
Console::WriteLine(S"The PortType with the name {0} exists: {1}",
myNewPortType->Name, __box(bContains));
Console::WriteLine(S"Total number of PortTypes after removing: {0}",
__box(myServiceDescription->PortTypes->Count));
Console::WriteLine(S"Adding a PortType: {0}", myNewPortType->Name);
// Add a new portType from the collection.
myPortTypeCollection->Add(myNewPortType);
// Display the number of portTypes after adding a port.
Console::WriteLine(S"Total number of PortTypes after adding a new port: {0}",
__box(myServiceDescription->PortTypes->Count));
// List the PortTypes available in the WSDL document.
IEnumerator* myEnum = myPortTypeCollection->GetEnumerator();
while (myEnum->MoveNext())
{
PortType* myPortType = __try_cast<PortType*>(myEnum->Current);
Console::WriteLine(S"The PortType name is: {0}", myPortType->Name);
}
myServiceDescription->Write(S"MathService_New.wsdl");
}
catch(Exception* e)
{
Console::WriteLine(S"Exception: {0}", e->Message);
}
}
System::Object
System.Collections::CollectionBase
System.Web.Services.Description::ServiceDescriptionBaseCollection
System.Web.Services.Description::PortTypeCollection
System.Collections::CollectionBase
System.Web.Services.Description::ServiceDescriptionBaseCollection
System.Web.Services.Description::PortTypeCollection
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.
Show: