0

wsHttpBindingとそれを呼び出すクライアントを使用するWCFサービスを構築しました。
しかし、それでも次のエラーメッセージが表示されます。

An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.

内部の例外は次のとおりです。

An error occurred when processing the security tokens in the message.

これがサービスの設定ファイルです:

   <configuration>
     <system.serviceModel>
       <bindings>
         <wsHttpBinding>
           <binding name="myWsBinding">
             <security>
               <message negotiateServiceCredential="false" algorithmSuite="Basic128"
                 establishSecurityContext="false" />
             </security>
           </binding>
         </wsHttpBinding>
       </bindings>
       <services>
         <service behaviorConfiguration="ServiceBehavior" name="HelloWorldService.HelloService">
           <endpoint address="" binding="wsHttpBinding" bindingConfiguration="myWsBinding"
             contract="HelloWorldService.IHelloService">
             <identity>
               <servicePrincipalName value="host/MAGBAREYA"/>
             </identity>
           </endpoint>
           <host>
             <baseAddresses>
               <add baseAddress="http://localhost:8999/myService" />
             </baseAddresses>
           </host>
         </service>
       </services>
       <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior">
              <serviceDebug includeExceptionDetailInFaults="true" />
              <serviceMetadata httpGetEnabled="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>

クライアント設定ファイルは次のとおりです。

 <?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_IHelloService">
                    <security mode="Message">
                        <message clientCredentialType="Windows" negotiateServiceCredential="false"
                            algorithmSuite="Basic128" establishSecurityContext="false" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:8999/myService" binding="wsHttpBinding"
                bindingConfiguration="WSHttpBinding_IHelloService" contract="ServiceReference1.IHelloService"
                name="WSHttpBinding_IHelloService">
                <identity>
                    <servicePrincipalName value="host/MAGBAREYA"/>
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

問題のある構成は、negotiateServiceCredential="false"です。
サービスとクライアントの両方でtrueに設定すると、クライアントは完全に機能します(この変更を除いて、上記の構成ファイルを使用します)

誰かが私がここで何が恋しいのか教えてもらえますか?

前もって感謝します。

4

1 に答える 1

0

もっとロギングを有効にしようと思います。サーバーでは、次のようにサービスの構成ファイルで WCF メッセージ全体のログを有効にして、開始することができます。

 <system.diagnostics>
<sources>
  <source name="System.ServiceModel.MessageLogging">
    <listeners>
             <add name="messages"
             type="System.Diagnostics.XmlWriterTraceListener"
             initializeData="c:\logs\messages.svclog" />
      </listeners>
  </source>
</sources>
</system.diagnostics>

<system.serviceModel>
<diagnostics>
<messageLogging 
     logEntireMessage="true" 
     logMalformedMessages="false"
     logMessagesAtServiceLevel="true" 
     logMessagesAtTransportLevel="false"
     maxMessagesToLog="3000"
     maxSizeOfMessageToLog="2000"/>
  </diagnostics>
</system.serviceModel>

これを行った後、クライアントを再度テストして例外を再作成し、ツールsvctraceviewerを使用して .svclog ファイルを調べることができます。

于 2018-07-30T16:02:21.197 に答える