0

Windows 認証を使用して IIS で WCF Web サービスをホストしようとしています。制限により、basicHttpBinding と偽装を使用する必要があります (チェーンのリソースにアクセスするために、呼び出し元の ID を偽装します)。

WCF サービスの操作コントラクトで偽装を宣言的に有効にしました。

 [OperationBehavior(Impersonation = ImpersonationOption.Required)]

私のweb.configは次のとおりです。

    <system.serviceModel>
      <behaviors>
        <serviceBehaviors>
          <behavior>
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="true"/>
          </behavior>
        </serviceBehaviors>
      </behaviors>
      <bindings>
        <basicHttpBinding>        
          <binding name="basic">          
            <security mode="TransportCredentialOnly">
              <transport clientCredentialType="Windows">              
              </transport>            
            </security>          
          </binding>
        </basicHttpBinding>
      </bindings>
      <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      <services>
        <service name="NotesService">
          <endpoint address="http://Client1.osp.local:15000/NotesService/NotesService.svc" bindingConfiguration="basic" binding="basicHttpBinding"  contract="NotesService.ServiceContract.INotesService">
            <identity>
              <servicePrincipalName value="HTTP/Client1.osp.local:15000"/>            
            </identity>          
          </endpoint>        
        </service>
      </services>
    </system.serviceModel>

ただし、アクティベーション エラーが発生します。私は何が欠けていますか?

私が得ているエラーは次のとおりです。

The contract operation 'Process' requires Windows identity for automatic 
impersonation. A Windows identity that represents the caller is not provided by 
binding ('BasicHttpBinding','http://tempuri.org/') for contract 
('NotesService','http://tempuri.org/'.
4

1 に答える 1

2

WCF 4.0 を使用していると仮定すると、既定のエンドポイントと呼ばれる WCF 4 機能のアーティファクトが表示されていると思います。

サービス名には、サービスの完全修飾名 (名前空間を含む) を指定する必要があります。NotesService が名前空間にあると仮定すると、ServiceHost を作成しても、構成ファイルで一致するものは見つかりません。ServiceHost コンストラクターで HTTP ベース アドレスを指定すると、basicHttpBinding がデフォルトの構成 (認証なし) で接続され、表示されているエラーが発生します。

于 2011-07-13T21:34:00.597 に答える