44

テストのために、クライアント コンソール アプリケーションからサーバー上の WCF サービスにアクセスしようとしています。次のエラーが表示されます。

呼び出し元がサービスによって認証されませんでした

を使用してwsHttpBindingいます。サービスが期待している認証の種類がわかりません。



<behaviors>
  <serviceBehaviors>
    <behavior name="MyTrakerService.MyTrakerServiceBehavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

更新IIS 7.0 でホストされている Windows 2008 サーバーで バインディングを<endpoint "basicHttpBinding" ... />(wsHttpBinding から)に変更すると機能します

4

10 に答える 10

26

basicHttpBinding を使用する場合は、エンドポイント セキュリティを「None」に設定し、clientCredintialType を「None」に転送します。

<bindings>
    <basicHttpBinding>
        <binding name="MyBasicHttpBinding">
            <security mode="None">
                <transport clientCredentialType="None" />
            </security>
        </binding>
    </basicHttpBinding>
</bindings>
<services>
    <service behaviorConfiguration="MyServiceBehavior" name="MyService">
        <endpoint 
            binding="basicHttpBinding" 
            bindingConfiguration="MyBasicHttpBinding"
            name="basicEndPoint"    
            contract="IMyService" 
        />
</service>

また、IIS のディレクトリ認証方法が匿名アクセスを有効にしていることを確認してください。

于 2008-11-12T19:33:10.307 に答える
24

わかった。

wshttpbinding を使用する場合は、以下のように Windows 資格情報を追加する必要があります。

svc.ClientCredentials.Windows.ClientCredential.UserName = "abc";
svc.ClientCredentials.Windows.ClientCredential.Password = "xxx";

ありがとう

于 2009-02-25T23:42:14.823 に答える
4

wsHttpBinding の代わりに basicHttpBinding を使用してみましたか? 認証が必要なく、Ws-* 実装も必要ない場合は、単純な古い basicHttpBinding を使用する方がよいでしょう。WsHttpBinding は、メッセージのセキュリティと認証のために WS-Security を実装します。

于 2008-11-12T18:04:27.787 に答える
2

仮想ディレクトリに匿名アクセスを設定する

次の資格情報をサービスに書き込みます

ADTService.ServiceClient adtService = new ADTService.ServiceClient();
adtService.ClientCredentials.Windows.ClientCredential.UserName="windowsuseraccountname";
adtService.ClientCredentials.Windows.ClientCredential.Password="windowsuseraccountpassword";
adtService.ClientCredentials.Windows.ClientCredential.Domain="windowspcname";

その後、Web サービス メソッドを呼び出します。

于 2009-10-21T07:09:52.017 に答える
1

以下の手順に従って、共有の問題を解決できました。

  1. IIS -->サイト-->あなたのサイト-->に移動します。
  2. 機能ビュー ペイン -->認証
  3. 匿名認証無効に設定
  4. Windows 認証有効に設定する

ここに画像の説明を入力

于 2016-04-07T22:12:01.483 に答える
0

これは、クライアントがサーバーとは異なるドメインにある場合に発生する可能性があります。

PC(クライアント)から(クラウド)テストサーバーへのアプリケーションの1つをテストしているときにこれに遭遇しました。私が考えることができる最も簡単な解決策は、vpnを設定することでした.

于 2016-05-17T04:22:52.073 に答える
0

にも同じ問題がありましたwsHtppBindingsecurityそして、を指すモードを追加するだけでnone問題が解決し、に切り替える必要はありませんでしたbasicHttpBindingここを確認して、WCF セキュリティを無効にする方法を確認してください。参考までに、以下の設定変更を確認してください。

<wsHttpBinding>
    <binding name="soapBinding">
        <security mode="None">
            <transport clientCredentialType="None" />
            <message establishSecurityContext="false" />
        </security>
    </binding>
</wsHttpBinding>
于 2018-07-19T06:26:49.267 に答える
-2

wsHttpBinding (「メッセージ」または「トランスポート」ではなく「なし」) のセキュリティ設定を完全に削除できないのはなぜですか?

于 2009-11-03T06:29:06.453 に答える