ServiceEndpoint.Name Propriedade

Definição

Obtém ou define o nome do ponto de extremidade de serviço.Gets or sets the name of the service endpoint.

public:
 property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
public string Name { get; set; }
member this.Name : string with get, set
Public Property Name As String

Valor da propriedade

String

O nome do ponto de extremidade de serviço.The name the service endpoint. O valor padrão é a concatenação do nome da associação e o nome da descrição do contrato.The default value is the concatenation of the binding name and the contract description name. Por exemplo, Name + ' _ ' + Name .For example, Name +'_' + Name.

Exemplos

Uri baseAddress = new Uri("http://localhost:8001/Simple");
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

ServiceEndpoint endpoint = serviceHost.AddServiceEndpoint(
    typeof(ICalculator),
    new WSHttpBinding(),
    "CalculatorServiceObject");

Console.WriteLine("Service endpoint {0} contains the following:", endpoint.Name);
Console.WriteLine("Binding: {0}", endpoint.Binding.ToString());
Console.WriteLine("Contract: {0}", endpoint.Contract.ToString());
Console.WriteLine("ListenUri: {0}", endpoint.ListenUri.ToString());
Console.WriteLine("ListenUriMode: {0}", endpoint.ListenUriMode.ToString());
Dim baseAddress As New Uri("http://localhost:8001/Simple")
Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)

Dim endpoint As ServiceEndpoint = serviceHost.AddServiceEndpoint(GetType(ICalculator), New WSHttpBinding(), "CalculatorServiceObject")

Console.WriteLine("Service endpoint {0} contains the following:", endpoint.Name)
Console.WriteLine("Binding: {0}", endpoint.Binding.ToString())
Console.WriteLine("Contract: {0}", endpoint.Contract.ToString())
Console.WriteLine("ListenUri: {0}", endpoint.ListenUri.ToString())
Console.WriteLine("ListenUriMode: {0}", endpoint.ListenUriMode.ToString())

Comentários

Os serviços podem ter vários pontos de extremidade, portanto, o ponto final Name é diferente do nome do serviço.Services may have multiple endpoints, so the endpoint Name is distinct from the name of the service. O nome do serviço é acessado usando a Name propriedade.The service name is accessed using the Name property.

Observação

Quando acessado por meio do serviço, essa propriedade é preenchida pelo elemento de configuração <Endpoint Name = " endpointName " > .When accessed from the service, this property is populated by the <endpoint name="endpointName"> configuration element. Quando acessado no cliente, essa propriedade é null .When accessed on the client, this property is null. Quando o getter da propriedade é chamado (novamente no cliente), ele popula essa propriedade com um valor padrão com base no contrato e na associação.When the property getter is called (again on the client) it populates this property with a default value based on the contract and binding.

Aplica-se a