Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

PortCollection Class

Represents a collection of instances of the Port class. This class cannot be inherited.

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)
public sealed class PortCollection : ServiceDescriptionBaseCollection
public final class PortCollection extends ServiceDescriptionBaseCollection
public final class PortCollection extends ServiceDescriptionBaseCollection
Not applicable.
Service myService;
PortCollection myPortCollection;

ServiceDescription myServiceDescription =
   ServiceDescription.Read("MathServiceItem_cs.wsdl");

Console.WriteLine("Total number of services : "
   + myServiceDescription.Services.Count);

for(int i=0; i < myServiceDescription.Services.Count; ++i)
{
   myService = myServiceDescription.Services[i];
   Console.WriteLine("Name : " + myService.Name);

   myPortCollection = myService.Ports;

   // Create an array of ports.
   Console.WriteLine("\nPort collection :");
   for(int i1=0 ; i1 < myService.Ports.Count ; ++i1)
   {
      Console.WriteLine("Port[" + i1+"] : " +
         myPortCollection[i1].Name);
   }

   string strPort = myPortCollection[0].Name;
   Port myPort = myPortCollection[strPort];
   Console.WriteLine("\nIndex of Port[" + strPort + "] : " +
      myPortCollection.IndexOf(myPort));


   Port myPortTestRemove = myPortCollection[0];

   Console.WriteLine("\nTotal number of ports before removing "
      + "a port '" + myPortTestRemove.Name +"' is : "
      + myService.Ports.Count);

   myPortCollection.Remove(myPortTestRemove);

   Console.WriteLine("Total number of ports after removing "
      + "a port '" + myPortTestRemove.Name +"' is : "
      + myService.Ports.Count);

   // Create the WSDL file.
   myPortCollection.Insert(0, myPortTestRemove);
   myServiceDescription.Write("MathServiceItemNew_cs.wsdl");

Service myService;
PortCollection myPortCollection;

ServiceDescription myServiceDescription = 
    ServiceDescription.Read("MathServiceItem_jsl.wsdl");

Console.WriteLine("Total number of services : " 
    + myServiceDescription.get_Services().get_Count());

for (int i = 0; i < myServiceDescription.get_Services().
    get_Count(); ++i) {
    myService = myServiceDescription.get_Services().get_Item(i);
    Console.WriteLine("Name : " + myService.get_Name());
    myPortCollection = myService.get_Ports();

    // Create an array of ports.
    Console.WriteLine("\nPort collection :");
    for (int i1 = 0; i1 < myService.get_Ports().get_Count();
        ++i1) {
        Console.WriteLine("Port[" + i1 + "] : " 
            + myPortCollection.get_Item(i1).get_Name());
    }

    String strPort = myPortCollection.get_Item(0).get_Name();
    Port myPort = myPortCollection.get_Item(strPort);
    Console.WriteLine("\nIndex of Port[" + strPort + "] : " 
        + myPortCollection.IndexOf(myPort));

    Port myPortTestRemove = myPortCollection.get_Item(0);

    Console.WriteLine("\nTotal number of ports before removing " 
        + "a port '" + myPortTestRemove.get_Name() + "' is : " 
        + myService.get_Ports().get_Count());

    myPortCollection.Remove(myPortTestRemove);

    Console.WriteLine("Total number of ports after removing " 
        + "a port '" + myPortTestRemove.get_Name() + "' is : " 
        + myService.get_Ports().get_Count());

    // Create the WSDL file.
    myPortCollection.Insert(0, myPortTestRemove);
    myServiceDescription.Write("MathServiceItemNew_jsl.wsdl");

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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:
© 2014 Microsoft. All rights reserved.