PortTypeCollection.Add Method (PortType)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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
)

Parameters

portType
Type: System.Web.Services.Description.PortType

The PortType to add to the collection.

Return Value

Type: System.Int32

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: " 
   + myServiceDescription.PortTypes.Count);

// Get the first PortType in the collection.
PortType myNewPortType = myPortTypeCollection[0];
Console.WriteLine(
   "The PortType at index 0 is: " + myNewPortType.Name);
Console.WriteLine("Removing the PortType " + myNewPortType.Name);

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

// Display the number of PortTypes.
Console.WriteLine("\nTotal number of PortTypes after removing: "
   + myServiceDescription.PortTypes.Count);

Console.WriteLine("Adding a PortType " + 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: " + myServiceDescription.PortTypes.Count);

myServiceDescription.Write("MathService_New.wsdl");

.NET Framework
Available since 1.1
Return to top
Show: