2011-08-10 153 views
0

我新的WCF和使用的WSHttpBinding,但我想删除的用户名和密码以服务客户端(我已经通过), 我的客户端代码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> 

仪式现在的服务是在Web托管。 在service.config或客户端应用程序.config中是否有任何更改。 在我的弱知识谷歌后,改变应该是客户端,但我无法做到这一点。 :-(

注意:我的合同要求的会议也提前 感谢名单

回答

0

您需要在服务器端更改web.config中,您的客户端的web.config会自动刷新后更新如果你不想使用登录/密码,我可以建议你建立一个双向证书认证。

这种方法是安全的,可以与其他WS协议栈(例如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