PortTypeCollection Class
.NET Framework 2.0
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.
Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)
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 ); } }
import System.*;
import System.Web.Services.Description.*;
import System.Xml.*;
import System.Collections.*;
class MyPortTypeCollectionClass
{
public static void main(String[] args)
{
try {
// Read the existing Web service description file.
ServiceDescription myServiceDescription = ServiceDescription.Read(
"MathService_JSL.wsdl");
PortTypeCollection myPortTypeCollection = myServiceDescription.
get_PortTypes();
int noOfPortTypes = myServiceDescription.get_PortTypes().
get_Count();
Console.WriteLine("\nTotal number of PortTypes: "
+ myServiceDescription.get_PortTypes().get_Count());
// Get the first PortType in the collection.
PortType myNewPortType = myPortTypeCollection.get_Item(
"MathServiceSoap");
int index = myPortTypeCollection.IndexOf(myNewPortType);
Console.WriteLine("The PortType with the name "
+ myNewPortType.get_Name() + " is at index: " + (index + 1));
Console.WriteLine("Removing the PortType: "
+ myNewPortType.get_Name());
// Remove the PortType from the collection.
myPortTypeCollection.Remove(myNewPortType);
boolean bContains = myPortTypeCollection.Contains(myNewPortType);
Console.WriteLine("The PortType with the name "
+ myNewPortType.get_Name() + " exists: "
+ System.Convert.ToString(bContains));
Console.WriteLine("Total number of PortTypes after removing: "
+ myServiceDescription.get_PortTypes().get_Count());
Console.WriteLine("Adding a PortType: "
+ myNewPortType.get_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: " + myServiceDescription.get_PortTypes().
get_Count());
// List the PortTypes available in the WSDL document.
for (int iCtr = 0; iCtr < myPortTypeCollection.get_Count(); iCtr++) {
PortType myPortType = myPortTypeCollection.get_Item(iCtr);
Console.WriteLine("The PortType name is: "
+ myPortType.get_Name());
}
myServiceDescription.Write("MathService_New.wsdl");
}
catch (System.Exception e) {
Console.WriteLine("Exception: " + e.get_Message());
}
} //main
} //MyPortTypeCollectionClass
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 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.Community Additions
ADD
Show: