码迷,mamicode.com
首页 > Windows程序 > 详细

C# WCF发布服务的元数据的方式

时间:2017-12-23 14:28:17      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:mode   发布   oca   add   blog   fse   point   sea   ext   

发布服务元数据的方式有两种:一是基于HTTP-GET协议提供元数据,它是一种绝大多数平台都能支持的简单text-based协议;另一种是元数据交换终结点。

1.基于HTTP-GET协议

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="HelloWCFService.HelloWCFService" behaviorConfiguration="metaExchange">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000/MyService"/>
          </baseAddresses>
        </host>
        <endpoint address="HelloWCFService" binding="wsHttpBinding" contract="HelloWCFService.IHelloWCFService"/>
        <!--<endpoint address="metaExchange" binding="mexHttpBinding" contract="IMetadataExchange"/>-->
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="metaExchange">
          <serviceMetadata httpGetEnabled="true"/>
          <!--<serviceMetadata/>-->
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

2.元数据交换终结点

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="HelloWCFService.HelloWCFService" behaviorConfiguration="metaExchange">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000/MyService"/>
          </baseAddresses>
        </host>
        <endpoint address="HelloWCFService" binding="wsHttpBinding" contract="HelloWCFService.IHelloWCFService"/>
        <endpoint address="metaExchange" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="metaExchange">
          <!--<serviceMetadata httpGetEnabled="true"/>-->
          <serviceMetadata/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

  

C# WCF发布服务的元数据的方式

标签:mode   发布   oca   add   blog   fse   point   sea   ext   

原文地址:http://www.cnblogs.com/LicwStack/p/8093034.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!