This documentation is archived and is not being maintained.

Port Class

Defines an individual endpoint contained in the XML Web service. This class cannot be inherited.

For a list of all members of this type, see Port Members.

System.Object
   System.Web.Services.Description.DocumentableItem
      System.Web.Services.Description.Port

[Visual Basic]
NotInheritable Public Class Port
   Inherits DocumentableItem
[C#]
public sealed class Port : DocumentableItem
[C++]
public __gc __sealed class Port : public DocumentableItem
[JScript]
public class Port extends DocumentableItem

Thread Safety

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

Remarks

This class specifies a single address (URI) for a Binding, which defines message format and protocol details for operations and messages for a given PortType. The Binding property gets or sets those values for a specified Port.

This class corresponds to the Web Services Description Language (WSDL) <port> element, which is enclosed by the <service> element. For more information about WSDL, see the specification at http://www.w3.org/TR/wsdl.

Example

[Visual Basic] 

         ' Create a Port.
         Dim postPort As New Port()
         postPort.Name = "PortServiceHttpPost"
         postPort.Binding = New XmlQualifiedName("s0:PortServiceHttpPost")


         ' Create an HttpAddressBinding.
         Dim postAddressBinding As New HttpAddressBinding()
         postAddressBinding.Location = _
            "http://localhost/PortClass/PortService.vb.asmx"

         ' Add the HttpAddressBinding to the Port.
         postPort.Extensions.Add(postAddressBinding)

         ' Get the Service of the postPort.
         Dim myService As Service = postPort.Service

         ' Print the service name for the port.
         Console.WriteLine("This is the service name of the postPort:*" & _
            myDescription.Services(0).Ports(0).Service.Name & "*")

         ' Add the Port to the PortCollection of the ServiceDescription.
         myDescription.Services(0).Ports.Add(postPort)


[C#] 
// Create a Port.
Port postPort = new Port();
postPort.Name = "PortServiceHttpPost";
postPort.Binding = new XmlQualifiedName("s0:PortServiceHttpPost");

// Create an HttpAddressBinding.
HttpAddressBinding postAddressBinding = new HttpAddressBinding();
postAddressBinding.Location = 
   "http://localhost/PortClass/PortService_cs.asmx";

// Add the HttpAddressBinding to the Port.
postPort.Extensions.Add(postAddressBinding);

// Get the Service of the postPort.
Service myService = postPort.Service;

// Print the service name for the port.
Console.WriteLine("This is the service name of the postPort:*" +
   myDescription.Services[0].Ports[0].Service.Name + "*");

// Add the Port to the PortCollection of the ServiceDescription.
myDescription.Services[0].Ports.Add(postPort);

[C++] 
// Create a Port.
Port* postPort = new Port();
postPort->Name = S"PortServiceHttpPost";
postPort->Binding = new XmlQualifiedName(S"s0:PortServiceHttpPost");

// Create an HttpAddressBinding.
HttpAddressBinding* postAddressBinding = new HttpAddressBinding();
postAddressBinding->Location = 
   S"http://localhost/PortClass/PortService_cs.asmx";

// Add the HttpAddressBinding to the Port.
postPort->Extensions->Add(postAddressBinding);

// Get the Service of the postPort.
Service* myService = postPort->Service;

// Print the service name for the port.
Console::WriteLine(S"This is the service name of the postPort:*{0}*",
   myDescription->Services->Item[0]->Ports->Item[0]->Service->Name);

// Add the Port to the PortCollection of the ServiceDescription.
myDescription->Services->Item[0]->Ports->Add(postPort);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.Services.Description

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Web.Services (in System.Web.Services.dll)

See Also

Port Members | System.Web.Services.Description Namespace | Service

Show: