在阅读博客园 WCF开发实战系列一:创建第一个WCF服务 一文中,发现手动配置App.config还是有难度。这篇文章没讲很多原理性的内容,直接以WCF项目创建开始,很适合想快速上手WCF的同学。
在这里把App.config中的注意点标识出来,一遍大家能够快速掌握。
<system.serviceModel> <services> <service behaviorConfiguration="Services.Service1Behavior" name="MyWCFTest2.BookService"> <endpoint address="" binding="wsHttpBinding" contract="MyWCFTest2.IBookService"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://localhost:8731/Design_Time_Addresses/MyWCFTest2/BookService/" /> </baseAddresses> </host> </service> </services> <behaviors> <serviceBehaviors> <behavior name="Services.Service1Behavior"> <!--为避免泄漏元数据信息, 请在部署前将以下值设置为 false 并删除上面的元数据终结点--> <serviceMetadata httpGetEnabled="True"/> <!--要接收故障异常详细信息以进行调试, 请将下值设置为 true。在部署前 设置为 false 以避免泄漏异常信息--> <serviceDebug includeExceptionDetailInFaults="False" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration>
如上黄色背景的都是需要修改成自己项目名字的。共勉!