WCF配置小结

来源:互联网 发布:网站源码什么意思 编辑:程序博客网 时间:2024/04/29 20:07

一.基于命名管道的内部进程通信

1.宿主程序App.config

命名空间:DMBQWCF,具体的服务类:Service1

<?xml version="1.0" encoding="utf-8"?></span>
<configuration>   <system.serviceModel>  <services>    <service behaviorConfiguration="metadataSupport" name="DMBQWCF.Service1">      <endpoint address="net.pipe://localhost/" binding="netNamedPipeBinding"        bindingConfiguration="" name="节点1" contract="DMBQWCF.IService1" />    </service>  </services>  <behaviors>    <serviceBehaviors>      <behavior name="metadataSupport">        <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8002/Service1"/>      </behavior>    </serviceBehaviors>  </behaviors>  </system.serviceModel></configuration>

2.客户程序配置App.config

<?xml version="1.0" encoding="utf-8" ?><configuration>    <system.serviceModel>        <bindings>            <basicHttpBinding>                <binding name="BasicHttpBinding_IService1" />            </basicHttpBinding>        </bindings>        <client>            <endpoint address="net.pipe://localhost/" binding="netNamedPipeBinding"                bindingConfiguration="" contract="WCFServer.IService1" name="BasicHttpBinding_IService1" />        </client>    </system.serviceModel></configuration>

二.基于HTTP的通信

1.宿主程序App.config

命名空间:DMBQWCF,具体的服务类:Service1


<?xml version="1.0" encoding="utf-8"?><configuration>   <system.serviceModel>  <services>    <service name="DMBQWCF.Service1" behaviorConfiguration="metadataSupport">      <endpoint address="http://localhost:8007/"               binding="basicHttpBinding"               contract="DMBQWCF.IService1" />    </service>  </services>  <behaviors>    <serviceBehaviors>      <behavior name="metadataSupport">        <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8002/Service1"/>      </behavior>    </serviceBehaviors>  </behaviors>  </system.serviceModel></configuration>
2.客户程序配置App.config

<?xml version="1.0" encoding="utf-8" ?><configuration>    <system.serviceModel>        <bindings>            <basicHttpBinding>                <binding name="BasicHttpBinding_IService1" />            </basicHttpBinding>        </bindings>        <client>            <endpoint address="http://localhost:8007/" binding="basicHttpBinding"                bindingConfiguration="BasicHttpBinding_IService1" contract="WCFServer.IService1"                name="BasicHttpBinding_IService1" />        </client>    </system.serviceModel></configuration>



0 0
原创粉丝点击