发布服务元数据的方式有两种:一是基于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>