两个基本WCF应用技巧总结

在学习WCF开发工具的过程中,我们需要在不断的实践中去慢慢积累经验,来充实我们所掌握的应用技巧,这样才能应用于自如。在这里我们就为大家介绍两种常见的WCF应用技巧,方便大家掌握。#t#

WCF应用技巧1、生成证书

makecert -r -pe -n CN="MyWebServer" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localmachine -sky exchange

-sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12

WCF应用技巧2、config配置

 
 
 
  1. < endpoint address ="" binding="wsHttpBinding" 
    contract="WcfService.IService1" 
    bindingConfiguration="EndpointBinding"> 

 

部署时,应删除或替换下列标识元素,以反映在其下运行部署服务的标识。删除之后,WCF 将自动推导相应标识。

 
 
 
  1. < identity> 
  2. < dns value="MyWebServer"/> 
  3. < /identity> 
  4. < /endpoint> 

 
 
 
  1. < bindings> 
  2. < wsHttpBinding> 
  3. < binding name="EndpointBinding"> 
  4. < security mode="Message"> 
  5. < transport clientCredentialType="Windows" 
    proxyCredentialType="Windows"/> 
  6. < message clientCredentialType="UserName"/> 
  7. < /security> 
  8. < /binding> 
  9. < /wsHttpBinding> 
  10. < /bindings> 

 

 
 
 
  1. < serviceCredentials> 
  2. < serviceCertificate findValue="MyWebServer" 
  3. x509FindType="FindBySubjectName" 
  4. storeLocation="LocalMachine" 
  5. storeName="My"/> 
  6. < userNameAuthentication userNamePasswordValidationMode="Custom"
     customUserNamePasswordValidatorType="WcfService.Models.
    CustomUserPassword,WcfService"
     /> 
  7. < /serviceCredentials> 

以上就是我们为大家总结的WCF应用技巧。

THE END