2011-08-10 17 views
0

をWSHttpBinding私のクライアントコードが結合、クライアント認証

RServiceClient serviceClient = new RServiceClient(); 
serviceClient.ClientCredentials.Windows.ClientCredential.UserName = "UserName"; 
serviceClient.ClientCredentials.Windows.ClientCredential.Password = "Password"; 
ある 、(私は渡す必要がある)私は、WCFに新しいとwshttpbindingを使用していますが、私はサービスクライアントを構成するユーザー名とパスワードを削除したいです

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

私のクライアントの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> 

儀式今のサービスは、Webでホストされています。 service.configまたはクライアント側のアプリケーション.configに変更があります。 googleingの後の私の弱い知識の は、変更がクライアント側でなければならないが、私はそれを行うことができないということです。 :-(

注:。。私の契約は、あまりにもセッションを必要と ありがとうを事前に

答えて

0

あなたは、サーバー側でweb.configファイルを変更する必要がある、あなたのクライアントのweb.configファイルが自動的にリフレッシュした後に更新されます ログイン/パスワードを使用したくない場合は、相互証明書認証の設定をアドバイスできます。

このアプローチは、他のWSスタック(eq。Java CXF、..など)と安全かつ相互運用できます。 )

相互認証の場合: X.509証明書が必要になります。これにより、クライアントが本当に誰であるかを確かめ、クライアント側で他のX.509証明書を確認することができます。ここで

MSDNでweb.configファイルの例、より多くの情報:

<?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> 
+0

は私が求めています厥、service.configの変化は何ですか?これは私の設定です。 <行動名= "RServiceBehavior"> <サービスbehaviorConfiguration = "RServiceBehavior" 名前= "EHRService"><エンドポイントアドレス= "" バインディング= "wsHttpBinding" 契約= "ServiceContracts.IRService"> user765573

関連する問題