0

私はwcfを初めて使用し、wshttpbindingを使用していますが、サービスクライアントからユーザー名とパスワードを削除したい(これを渡す必要があります)、私のクライアントコードは

RServiceClient serviceClient = new RServiceClient();
serviceClient.ClientCredentials.Windows.ClientCredential.UserName = "UserName";
serviceClient.ClientCredentials.Windows.ClientCredential.Password = "Password";

このユーザー名とパスワードを渡したくありません。

私のクライアント app.config は次のとおりです。

     <binding name="WSHttpBinding_IRService" 
              closeTimeout="00:01:00"
              openTimeout="00:01:00" 
              receiveTimeout="00:10:00" 
              sendTimeout="00:01:00"
              bypassProxyOnLocal="false" 
              transactionFlow="false"    
              hostNameComparisonMode="StrongWildcard"
              maxBufferPoolSize="524288" 
              maxReceivedMessageSize="65536"
              messageEncoding="Text" 
              textEncoding="utf-8" 
              useDefaultWebProxy="true"
              allowCookies="false">
              <readerQuotas maxDepth="32" 
                            maxStringContentLength="8192" 
                            maxArrayLength="16384"
                            maxBytesPerRead="4096" 
                            maxNameTableCharCount="16384" />
              <reliableSession ordered="true" 
                               inactivityTimeout="00:10:00"
                               enabled="false" />
              <security mode="Message">
               <transport clientCredentialType="Windows" 
                          proxyCredentialType="None"
                          realm="" />
               <message clientCredentialType="Windows"                    
                        negotiateServiceCredential="true"
                        algorithmSuite="Default" />
              </security>
            </binding>

rit now サービスは Web でホストされています。service.config またはクライアント側 app.config に変更はありますか。ググった後の私の弱い知識では、変更はクライアント側でなければならないということですが、私はそれを行うことができません。:-(

注:私の契約にはセッションも必要です。事前に感謝します。

4

1 に答える 1

0

サーバー側で web.config を変更する必要があります。クライアントの web.config は、Web 参照の更新後に自動的に更新されます。ログイン/パスワードを使用したくない場合は、相互証明書認証を設定することをお勧めします。

このアプローチは安全で、他の WS スタック (Java CXF など) と相互運用可能です。

相互認証認証の場合: サーバーが本当に偽装している人であることをクライアントが確認できるようにする X.509 証明書と、クライアント側の別の X.509 証明書が必要です。

ここに web.config の例を示します。詳細についてはMSDNを参照してください。

   <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="serviceCredentialBehavior">
          <serviceCredentials>
            <serviceCertificate findValue="Contoso.com" 
                                storeLocation="LocalMachine"
                                storeName="My" 
                                x509FindType="FindBySubjectName" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="serviceCredentialBehavior" 
               name="ServiceModel.Calculator">
        <endpoint address="http://localhost/Calculator" 
                  binding="wsHttpBinding"
                  bindingConfiguration="InteropCertificateBinding"
                  name="WSHttpBinding_ICalculator"
                  contract="ServiceModel.ICalculator" />
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="InteropCertificateBinding">
          <security mode="Message">
            <message clientCredentialType="Certificate"
                     negotiateServiceCredential="false"
                     establishSecurityContext="false" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client />
  </system.serviceModel>
</configuration>
于 2011-08-10T10:26:10.033 に答える