WCF是一个由微软公司研发,主要应用于通信方面的.NET Framework 3.5的重要组成部件。我们今天将会为大家带来有关WCF通信方式的一些基本配置方法,希望能给大家带来一些帮助。
自定义托管宿主使用配置文件来定义服务的终结点和元数据交换节点,服务的交换行为等其他属性也在配置文件里给出,我们配置了三种不同的WCF通信方式,分别是http、tcp、IPC.具体配置信息如下:
- < services>
- < service behaviorConfiguration="WCFService.WCFServiceBehavior"
name="WCFService.WCFService">- < endpoint
- address="http://localhost:9001/WCFService"
- binding="wsHttpBinding"
- contract="WCFService.IWCFOverLoadingService">
- < /endpoint>
- < endpoint
- address="net.tcp://localhost:9002/WCFService"
- binding="netTcpBinding"
- contract="WCFService.IWCFOverLoadingService">
- < /endpoint>
- < endpoint
- address="net.pipe://localhost/WCFService"
- binding="netNamedPipeBinding"
- contract="WCFService.IWCFOverLoadingService">
- < /endpoint>
- < endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />- < endpoint address="mex" binding="mexTcpBinding"
contract="IMetadataExchange" />- < endpoint address="mex" binding="mexNamedPipeBinding"
contract="IMetadataExchange" />- < host>
- < baseAddresses>
- < add baseAddress="http://localhost:9001/"/>
- < add baseAddress="net.tcp://localhost:9002/"/>
- < add baseAddress="net.pipe://localhost/"/>
- < /baseAddresses>
- < /host>
- < /service>
- < /services>
- < behaviors>
- < serviceBehaviors>
- < behavior name="WCFService.WCFServiceBehavior">
- < serviceMetadata httpGetEnabled="true" />
- < serviceDebug includeExceptionDetailInFaults="false" />
- < /behavior>
- < /serviceBehaviors>
- < /behaviors>
以上就是对WCF通信方式的相关配置方法。
【编辑推荐】