wcf 同时支持webhttp 和 引用方式

wcf 实现参考

http://www.cnblogs.com/mingmingruyuedlut/p/4223116.html

兼容两种方式  

1、修改服务端webconfig

<system.serviceModel>
    
    <services>
      <service name="xxx" behaviorConfiguration="Default">
        <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="basicTransport" contract="Ixxx"/>/*提供WebGet服务用*/
        <endpoint address="Wcf" binding="basicHttpBinding" contract="Ixxx"/>/*提供WCF服务 , 注意address='Wcf',为了区分开与WebGet的地址,添加引用之后会自动加上的 */
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>/*元数据endpoint*/
      </service>
    </services>
    
    <behaviors>      
      <serviceBehaviors>        
        <behavior name="Default">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>        
        <behavior name="">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>        
      </serviceBehaviors>
      
      <endpointBehaviors>
        <behavior name="web">
          <webHttp helpEnabled="true"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    
    <bindings>
      <webHttpBinding>
        <binding name="basicTransport"/>
      </webHttpBinding>
    </bindings>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    
  </system.serviceModel>

Web调用地址:http://ip:port/xxx.svc/yyy/id

  Wcf服务地址会变为:http://ip:port/xxx.svc/Wcf

posted @ 2016-10-27 18:03  炎蓝刀锋  阅读(1606)  评论(0编辑  收藏  举报

生活中快乐要多一点!