1首先上一张wcf通讯图
a.Proxy代理部分底层调用的是 xxxxClient=> ChannelFactory=>IInpuChannel/IOutChannel...
b.Transaction、Encoding、Security、transport这些则被封装在了协议栈里面 如BasicHttpBinding协议栈
2.很重要的一个知识点,当创建一个binding节点要使其有效,我们要在endPoint节点中添加一个bindingConfiguration的属性,将属性值设置成我们定义的binding节点的名字。
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> </startup> <system.serviceModel> <!--以下 新加入的bindings节点--> <bindings> <netTcpBinding> <binding name="MyBinding"> <security mode="None"></security><!--不要安全--> </binding> </netTcpBinding> </bindings> <!--以上 新加入的bindings节点--> <behaviors> <serviceBehaviors> <behavior name=""> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <services> <service name="WcfService.HomeService"> <host> <baseAddresses> <!--<add baseAddress="http://localhost:8733/Design_Time_Addresses/WcfService/HomeService/" />--> <add baseAddress="http://localhost:8733/Design_Time_Addresses/WcfService/HomeService" /> </baseAddresses> </host> <!--在endPoint这个节点的最后加入了属性 MyBinding--> <endpoint address="" binding="netTcpBinding" contract="WcfService.IHomeService" bindingConfiguration="MyBinding"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> </system.serviceModel> </configuration>