ServiceMetadataBehavior.HttpGetUrl Propriedade
Definição
Obtém ou define o local de publicação de metadados para solicitações HTTP/GET.Gets or sets the location of metadata publication for HTTP/GET requests.
public:
property Uri ^ HttpGetUrl { Uri ^ get(); void set(Uri ^ value); };
public Uri HttpGetUrl { get; set; }
[System.ComponentModel.TypeConverter(typeof(System.UriTypeConverter))]
public Uri HttpGetUrl { get; set; }
member this.HttpGetUrl : Uri with get, set
[<System.ComponentModel.TypeConverter(typeof(System.UriTypeConverter))>]
member this.HttpGetUrl : Uri with get, set
Public Property HttpGetUrl As Uri
Valor da propriedade
O local absoluto ou relativo dos metadados.The absolute or relative location of the metadata.
- Atributos
Exemplos
O exemplo de código a seguir demonstra o uso de ServiceMetadataBehavior em um arquivo de configuração para habilitar o suporte de metadados para solicitações HTTP/Get e WS-Transfer/Get.The following code example demonstrates the use of ServiceMetadataBehavior in a configuration file to enable metadata support for HTTP/GET and WS-Transfer/GET requests.
// Create a new metadata behavior object and set its properties to
// create a secure endpoint.
ServiceMetadataBehavior sb = new ServiceMetadataBehavior();
//sb.EnableHelpPage= true;
//sb.HttpsGetUrl = new Uri("https://myMachineName:8036/myEndpoint");
//myServiceHost.Description.Behaviors.Add(sb);
}
private void SnippetServiceMetadataBehavior()
{
// service for which <<indigo2>> automatically adds a
// ServiceMetadataBehavior to publish metadata as well as
// an HTML service help page
// from C_HowToSecureEndpoint\cs
// Create a new metadata behavior object and set its properties to
// create a secure endpoint.
ServiceMetadataBehavior sb = new ServiceMetadataBehavior();
/* sb.EnableHelpPage = true;
sb.enableMetadataExchange = true;
sb.HttpsGetUrl = new Uri("https://myMachineName:8036/myEndpoint");
myServiceHost.Description.Behaviors.Add(sb);
*/
}
private void Run()
{
// T:System.ServiceModel.ServiceMetadataBehavior
// <Snippet#0>
// Create a ServiceHost for the service type and use the base address from configuration.
ServiceHost host = new ServiceHost(typeof(SampleService));
try
{
ServiceMetadataBehavior metad
= host.Description.Behaviors.Find<ServiceMetadataBehavior>();
if (metad == null)
metad = new ServiceMetadataBehavior();
metad.HttpGetEnabled = true;
host.Description.Behaviors.Add(metad);
host.AddServiceEndpoint(
ServiceMetadataBehavior.MexContractName,
MetadataExchangeBindings.CreateMexHttpBinding(),
"mex"
);
// The service can now be accessed.
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
// Close the ServiceHostBase to shutdown the service.
host.Close();
// </Snippet#0>
Comentários
Se o valor de HttpGetUrl for relativo, o endereço no qual os metadados são publicados é o endereço base e o endereço do serviço mais uma ?wsdl QueryString.If the value of HttpGetUrl is relative, the address at which the metadata is published is the base address and the service address plus a ?wsdl querystring.
Se o valor de HttpGetUrl for absoluto, o endereço no qual os metadados são publicados é esse valor mais uma ?wsdl QueryString.If the value of HttpGetUrl is absolute the address at which the metadata is published is this value plus a ?wsdl querystring.
Por exemplo, se o endereço do serviço for http://localhost:8080/CalculatorService e HttpGetUrl for uma cadeia de caracteres vazia, o endereço de metadados http/Get será http://localhost:8080/CalculatorService?wsdl .For example, if the service address is http://localhost:8080/CalculatorService and the HttpGetUrl is an empty string, the HTTP/GET metadata address is http://localhost:8080/CalculatorService?wsdl.