Export (0) Print
Expand All
0 out of 2 rated this helpful - Rate this topic

Port Class

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

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)
public sealed class Port : NamedItem
public final class Port extends NamedItem
public final class Port extends NamedItem
Not applicable.

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.

// 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);

// Create a Port.
Port postPort = new Port();
postPort.set_Name("PortServiceHttpPost");
postPort.set_Binding(
    new XmlQualifiedName("s0:PortServiceHttpPost"));

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

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

// Get the Service of the postPort.
Service myService = postPort.get_Service();

// Print the service name for the port.
Console.WriteLine("This is the service name of the postPort:*" 
    + myDescription.get_Services().get_Item(0).get_Ports().
    get_Item(0).get_Service().get_Name() + "*");
// Add the Port to the PortCollection of the ServiceDescription.
myDescription.get_Services().get_Item(0).get_Ports().Add(postPort);

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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.