2

匿名アクセスが無効になっている IIS 5.1 でホストされている WCF サービスがあります。以下は、サービスの構成方法を示す web.config ファイルの一部です。

<system.serviceModel>
   <bindings>
      <basicHttpBinding>
         <binding name="basicHttpBindingCfg">
            <security mode="TransportCredentialOnly">
               <transport clientCredentialType="Windows" />
            </security>
         </binding>
      </basicHttpBinding>
   </bindings>
   <services>
      <service behaviorConfiguration="ServiceBehavior" name="HelloService">
         <endpoint name="BasicHttpEndpoint" 
             address="" 
             binding="basicHttpBinding" 
             bindingConfiguration="basicHttpBindingCfg"
             contract="IHelloService">
         </endpoint>
         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
   </services>
   <behaviors>
      <serviceBehaviors>
         <behavior name="ServiceBehavior">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="false"/>
          </behavior>
      </serviceBehaviors>
   </behaviors>
</system.serviceModel>

このサービスが公開している操作をデスクトップ アプリケーションから呼び出すたびに、次のエラー メッセージが表示されます。

必要な偽装レベルが指定されていないか、指定された偽装レベルが無効です。

バインディング タイプとホスティング環境はクライアントによって事前に決定され、変更できないことに注意してください。

この問題の解決につながる可能性のあるヘルプをいただければ幸いです。

ありがとう!

編集:クライアントの構成方法は次のとおりです。

<system.serviceModel>
   <bindings>
      <basicHttpBinding>
         <binding name="BasicHttpEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00"
                receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <security mode="TransportCredentialOnly">
               <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
               <message clientCredentialType="UserName" algorithmSuite="Default" />
            </security>
         </binding>
      </basicHttpBinding>
   </bindings>
   <client>
      <endpoint name="BasicHttpEndpoint" 
          address="http://vm00000033871b.intra.pri/WCFServiceBasicHttp/HelloService.svc"
          binding="basicHttpBinding" 
          bindingConfiguration="BasicHttpEndpoint"
          contract="Proxy.IHelloService" />
   </client>
</system.serviceModel>
4

1 に答える 1

3

これを試して、現在のユーザーの Windows 資格情報を渡します。

Using proxy As New PRX.HelloServiceClient()
    proxy.ClientCredentials.Windows.AllowedImpersonationLevel = 
                                       TokenImpersonationLevel.Impersonation
    proxy.ChannelFactory.Credentials.Windows.ClientCredential = 
                                       CredentialCache.DefaultNetworkCredentials
    Dim message As String = proxy.Hello("Hi")
    MessageBox.Show(message)
End Using
于 2011-09-14T19:19:27.437 に答える