在学习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配置
< endpoint address ="" binding="wsHttpBinding"
contract="WcfService.IService1"
bindingConfiguration="EndpointBinding">
- 1.
- 2.
- 3.
部署时,应删除或替换下列标识元素,以反映在其下运行部署服务的标识。删除之后,WCF 将自动推导相应标识。
< identity>
< dns value="MyWebServer"/>
< /identity>
< /endpoint>
- 1.
- 2.
- 3.
- 4.
与
< bindings>
< wsHttpBinding>
< binding name="EndpointBinding">
< security mode="Message">
< transport clientCredentialType="Windows"
proxyCredentialType="Windows"/>
< message clientCredentialType="UserName"/>
< /security>
< /binding>
< /wsHttpBinding>
< /bindings>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
< serviceCredentials>
< serviceCertificate findValue="MyWebServer"
x509FindType="FindBySubjectName"
storeLocation="LocalMachine"
storeName="My"/>
< userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="WcfService.Models.
CustomUserPassword,WcfService" />
< /serviceCredentials>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
以上就是我们为大家总结的WCF应用技巧。