Port Class
Defines an individual endpoint contained in the XML Web service. This class cannot be inherited.
Assembly: System.Web.Services (in System.Web.Services.dll)
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.
The following examples creates a Port and adds it to the Ports collection of an existing ServiceDescription named myDescription.
// Create a Port. Port^ postPort = gcnew Port; postPort->Name = "PortServiceHttpPost"; postPort->Binding = gcnew XmlQualifiedName( "s0:PortServiceHttpPost" ); // Create an HttpAddressBinding. HttpAddressBinding^ postAddressBinding = gcnew 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:*{0}*", myDescription->Services[ 0 ]->Ports[ 0 ]->Service->Name ); // Add the Port to the PortCollection of the ServiceDescription. myDescription->Services[ 0 ]->Ports->Add( postPort );
// 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);
System.Web.Services.Description::DocumentableItem
System.Web.Services.Description::NamedItem
System.Web.Services.Description::Port
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.