PortTypeCollection.Add Method

Adds the specified PortType to the end of the PortTypeCollection.

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

public:
int Add (
	PortType^ portType
)
public int Add (
	PortType portType
)
public function Add (
	portType : PortType
) : int
Not applicable.

Parameters

portType

The PortType to add to the collection.

Return Value

The zero-based index where the portType parameter has been added.

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[ 0 ];
Console::WriteLine( "The PortType at index 0 is: {0}", myNewPortType->Name );
Console::WriteLine( "Removing the PortType {0}", myNewPortType->Name );

// Remove the PortType from the collection.
myPortTypeCollection->Remove( myNewPortType );

// Display the number of PortTypes.
Console::WriteLine( "\nTotal 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 );
myServiceDescription->Write( "MathService_New.wsdl" );

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(0);
Console.WriteLine("The PortType at index 0 is: " 
    + myNewPortType.get_Name());
Console.WriteLine("Removing the PortType " 
    + myNewPortType.get_Name());

// Remove the PortType from the collection.
myPortTypeCollection.Remove(myNewPortType);

// Display the number of PortTypes.
Console.WriteLine("\nTotal 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());
myServiceDescription.Write("MathService_New.wsdl");

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: