web-dev-qa-db-ja.com

ServiceMetadataBehaviorのHttpGetEnabledプロパティがtrueに設定され、HttpGetUrlプロパティが相対アドレスですが、httpbaseaddはありません。

ADFS対応のasp.netmvc2アプリケーションがあり、IISでHTTPSバインディング(ポート番号:443)を使用して構成されています。このサイトは、IISでDefaultWebSiteとして構成されています。同じソリューションに存在するSilverlightプロジェクトに使用されるasp.netmvc2プロジェクト内にWCFサービス:ChartsService.svcがあります。完了後ローカル開発環境でテストし、コードをより高い環境に展開しました。すべての環境で問題なく動作しました。StagingサーバーでSilverlightプロジェクトをスモークしようとすると、突然、以下のようにWCFエラーが発生します。 :

System.InvalidOperationException ServiceMetadataBehaviorのHttpGetEnabledプロパティがtrueに設定され、HttpGetUrlプロパティが相対アドレスですが、httpベースアドレスがありません。 httpベースアドレスを指定するか、HttpGetUrlを絶対アドレスに設定します。

System.ServiceModel.ServiceActivationException: The service '/ChartsService.svc' cannot be activated due to an exception during compilation.  The exception message is: The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address.  Either supply an http base address or set HttpGetUrl to an absolute address.. ---> System.InvalidOperationException: The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address.  Either supply an http base address or set HttpGetUrl to an absolute address.
   at System.ServiceModel.Description.ServiceMetadataBehavior.CreateHttpGetEndpoints(ServiceDescription description, ServiceHostBase Host, ServiceMetadataExtension mex)
   at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
   at System.ServiceModel.ServiceHostBase.InitializeRuntime()
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   --- End of inner exception stack trace ---
   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)

ステージングWebサーバーはIIS7.0を使用しています。現在、web.configに次の構成があります。

<behaviors>
        <serviceBehaviors>
            <behavior name="VATScan.Web.ChartsServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="DemoApp.Web.ChartsServiceBehavior" name="DemoApp.Web.ChartsService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="ServicesBinding" contract="DemoApp.Web.IChartsService" />
        </service>
    </services>

上記と同じ構成のステージングを除いて、すべての上位環境で引き続き正常に機能していることに驚かされます。

誰かがこの問題を解決するのを手伝ってもらえますか?

8

上記の答えは1つの解決策であり、ここに別の解決策があります。

これを試して:

<serviceBehaviors>
    <behavior name="VATScan.Web.ChartsServiceBehavior">
        <serviceMetadata httpGetEnabled="true" httpGetUrl="[your service address]" />
        <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
</serviceBehaviors>

[サービスアドレス]を「 http:// localhost:8080/ChartsServiceBehavior "」のように置き換えます

それはトリックをしましたか?

これを確認してください: https://social.msdn.Microsoft.com/Forums/vstudio/en-US/2fd858cb-8988-444f-868c-2ceea9cc9705/httpgetenabled-property?forum=wcf

2
Leo

以下のweb.configのコードでhttpGetEnabledをhttpsGetEnabledに変更しましたが、問題は解決しました。

<behaviors>
        <serviceBehaviors>
            <behavior name="DemoApp.Web.ChartsServiceBehavior">
                <serviceMetadata httpsGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="DemoApp.Web.ChartsServiceBehavior" name="DemoApp.Web.ChartsService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="ServicesBinding" contract="DemoApp.Web.IChartsService" />
        </service>
    </services>
20