首页 > Web开发 > 详细

wcf 同时支持webhttp 和 引用方式

时间:2016-10-27 20:11:22      阅读:329      评论:0      收藏:0      [点我收藏+]

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

wcf 同时支持webhttp 和 引用方式

原文:http://www.cnblogs.com/sdaulldd/p/6004960.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!