WCF无法配置WSDL发布

WCF无法配置WSDL发布,wcf,configuration,wsdl,Wcf,Configuration,Wsdl,我想为我创建的Web服务启用WSDL检索。我可以通过我创建的.svc文件“调用”Web服务: http://localhost/test.svc <%@ ServiceHost Language="C#" Debug="true" Service="Project.MyService" CodeBehind="MyService.svc.cs" %> 调用该页面会显示标准的.NET消息,其中说“此服务的元数据发布当前已禁用”。并给出启用发布的说明 我按照说明添加了web.con

我想为我创建的Web服务启用WSDL检索。我可以通过我创建的.svc文件“调用”Web服务:

http://localhost/test.svc

<%@ ServiceHost Language="C#" Debug="true" Service="Project.MyService" CodeBehind="MyService.svc.cs" %>

调用该页面会显示标准的.NET消息,其中说“此服务的元数据发布当前已禁用”。并给出启用发布的说明

我按照说明添加了web.config条目,但是调用会产生相同的结果。。。如何为我的Web服务启用WSDL发布?

web.config条目



mex端点和httpGetEnabled看起来正常。此链接更详细地介绍了该主题,可能会有所帮助


mex端点和httpGetEnabled看起来正常。此链接更详细地介绍了该主题,可能会有所帮助


听起来很疯狂,但只需从服务定义中删除behaviorConfiguration=“MyServiceTypeBehaviors”,并让行为匿名(没有名字)。它将继续存在

<services>
     <service name="WcfServiceLibrary1.IMyService" >
    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" 
              address="mex"
              />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/test.svc"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior >
      <serviceMetadata httpGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

听起来很疯狂,但只需从服务定义中删除behaviorConfiguration=“MyServiceTypeBehaviors”,并让行为匿名(没有名字)。它将继续存在

<services>
     <service name="WcfServiceLibrary1.IMyService" >
    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" 
              address="mex"
              />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/test.svc"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior >
      <serviceMetadata httpGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>


我最终使用了Visual Studio提供的WCF配置工具。这将产生与此类似的结果。谢谢Thx,这只花了我两个小时。命名这些行为对我来说再也没有意义了。我最终使用了VisualStudio提供的WCF配置工具。这将产生与此类似的结果。谢谢Thx,这只花了我两个小时。命名这些行为对我来说再也没有意义了。