服务器端使用证书来做“自定义用户名密码”认证方式,
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="NewBindingUName">
<security mode="Message">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WcfServiceApp.ServicesBehavior"
name="WcfServiceLib.Services">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="NewBindingUName"
contract="WcfServiceLib.IServices">
<identity>
<dns value="192.168.6.118" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://192.168.6.118/DotNet/OK/Test/WcfLibTest/WcfServiceApp/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfServiceApp.ServicesBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<serviceCertificate findValue="WCFServerCert" storeLocation="LocalMachine"
storeName="My" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="WcfServiceLib.CustomUserPassword,WcfServiceLib" />
<clientCertificate>
<authentication certificateValidationMode="None"/>
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="NewBindingUName">
<security mode="Message">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WcfServiceApp.ServicesBehavior"
name="WcfServiceLib.Services">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="NewBindingUName"
contract="WcfServiceLib.IServices">
<identity>
<dns value="192.168.6.118" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://192.168.6.118/DotNet/OK/Test/WcfLibTest/WcfServiceApp/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfServiceApp.ServicesBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<serviceCertificate findValue="WCFServerCert" storeLocation="LocalMachine"
storeName="My" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="WcfServiceLib.CustomUserPassword,WcfServiceLib" />
<clientCertificate>
<authentication certificateValidationMode="None"/>
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>