我试图创建svc-less wcf服务。服务有效,但没有生成元数据。 如何返回服务元数据?
答案 0 :(得分:0)
您是否在代码中向服务生成添加了元数据端点?
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.HttpGetUrl = new Uri(EndPointAddress);
Host.Description.Behaviors.Add(smb);
或使用配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="yourServiceName"
behaviorConfiguration="yourBehavior">
<host>
<baseAddresses>
<add baseAddress = "yourBaseAddress" />
</baseAddresses>
</host>
<endpoint address ="..."
binding="httpBinding"
contract="..." />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="yourBehavior">
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
答案 1 :(得分:0)
找到解决方案 here: