ServiceMetadataBehavior.HttpGetEnabled ServiceMetadataBehavior.HttpGetEnabled ServiceMetadataBehavior.HttpGetEnabled ServiceMetadataBehavior.HttpGetEnabled Property

定義

HTTP/GET 要求を使用した取得用にサービス メタデータを公開するかどうかを示す値を取得または設定します。Gets or sets a value that indicates whether to publish service metadata for retrieval using an HTTP/GET request.

public:
 property bool HttpGetEnabled { bool get(); void set(bool value); };
public bool HttpGetEnabled { get; set; }
member this.HttpGetEnabled : bool with get, set
Public Property HttpGetEnabled As Boolean

プロパティ値

WSDL を公開する場合は true。それ以外の場合は falsetrue if the WSDL is published; otherwise, false. 既定値は、false です。The default is false.

構成ファイルで ServiceMetadataBehavior を使用して HTTP/GET および 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>

注釈

HttpGetUrl の値が相対値の場合、メタデータが公開されるアドレスは、ベース アドレスとサービス アドレスに ?wsdl クエリ文字列を加えたものになります。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.

HttpGetUrl の値が絶対値の場合、メタデータが公開されるアドレスは、HttpGetUrl 値に ?wsdl クエリ文字列を加えたものになります。If the value of HttpGetUrl is absolute the address at which the metadata is published is the value of HttpGetUrl value plus a ?wsdl querystring.

たとえば、サービス アドレスが http://localhost:8080/CalculatorService で、HttpGetUrl が空の文字列の場合、HTTP/GET メタデータ アドレスは 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.

このプロパティを有効にせず、HttpGetUrl を変更しないかまたは相対アドレスに設定した場合、HTTP のベース アドレスを指定せずにサービス ホストを開くとランタイムで例外がスローされます。If you do not enable this property and do not change HttpGetUrl or set it to a relative address, an exception is thrown at runtime when the service host is opened without a base address for HTTP.

適用対象