2011-09-12 18 views
1

WindowsサービスでホストされるWCFサービスに基本認証を追加するにはどうすればよいですか?WCFに基本認証を追加するWindowsサービスでホストされるサービス

バインディングにセキュリティタグを追加しましたが、ブラウザでサービスURLを呼び出すと認証ウィンドウが表示されません。私は何が間違っている/私は行方不明ですか?

<bindings> 
    <basicHttpBinding> 
    <binding name="MyDefaultBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000"> 
     <readerQuotas maxDepth="500" maxArrayLength="20000000" maxStringContentLength="20000000"/> 
    <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Basic" /> 
    </security> 
    </binding> 
    </basicHttpBinding> 
</bindings> 

答えて

4

サービスヘルパーページにアクセスするだけでは、認証ウィンドウが表示されません。認証はサービス・エンドポイント用に構成されています。ヘルパー・ページやWSDL用ではありません(「別個のエンドポイント」)。

は、あなたの設定を変更してください:

<bindings> 
    <customBinding> 
    <binding name="securedPages"> 
     <textMessageEncoding messageVersion="None" /> 
     <httpsTransport authenticationScheme="Basic" /> 
    </binding> 
    <customBinding> 
    <basicHttpBinding> 
    <binding name="MyDefaultBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000"> 
     <readerQuotas maxDepth="500" maxArrayLength="20000000" maxStringContentLength="20000000"/> 
     <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Basic" /> 
     </security> 
    </binding> 
    </basicHttpBinding> 
</bindings> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="securedService"> 
     <serviceMetadata httpGetEnabled="true" httpGetBinding="customBinding" 
         httpGetBindingConfiguration="securedPages" /> 
     <serviceDebug httpHelpPageEnabled="true" httpHelpPageBinding="customBinding" 
        httpHelpPageBindingConfiguration="securedPages" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<services> 
    <service name="..." behaviorConfiguration="securedService"> 
    ... 
    </service> 
</services> 
関連する問題