繁体   English   中英

WCF服务库(IIS):该服务的元数据发布当前被禁用

[英]WCF Service Library (IIS): Metadata publishing for this service is currently disabled

我收到此错误,无法撼动。 这个问题类似于这个SO问题,还有很多其他问题,更不用说页面本身了。

是的,我完全认识到namespaceservice name必须完全匹配。 我现在读到那笔钱不折不扣。

我有一个WCF服务库,该库正在IIS中运行。 该服务器是Windows Server 2016 Standard版。 我改名App.configWeb.config ,尽管我试图为App.config 我尝试了每个似乎无数的配置,并且仍然是相同的错误。 是的,我尝试添加绑定并指定basicHttpBinding

Web.Config中

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>

        <services>
            <service name="MyTesterLibrary.MyTester" behaviorConfiguration="MetadataBehavior">
                <endpoint address="" binding="wsHttpBinding" contract="MyTesterLibrary.IMyTester" />
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
        </services>

        <behaviors>
            <serviceBehaviors>
                <behavior name="MetadataBehavior">
                    <serviceMetadata httpGetEnabled="True"/>
                    <serviceDebug includeExceptionDetailInFaults="True" httpHelpPageEnabled="True" />
                </behavior>
            </serviceBehaviors>
        </behaviors>

    </system.serviceModel>
</configuration>

主班

namespace MyTesterLibrary
{
    public class MyTester : IMyTester
    {
        public string GetVersionInfo()
        {
            Backup.GetVersionInfo(out string response);

            return response;
        }
    }
}

接口类别

namespace MyTesterLibrary
{
    [ServiceContract]
    public interface IMyTester
    {
        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/GetVersionInfo")]
        [OperationContract]
        string GetVersionInfo();
    }
}

ProductServiceHost.svc

<%@ ServiceHost Service="MyTesterLibrary.MyTester" %>

我按照另一个站点上的说明进行操作,并创建了IIS站点。 此屏幕快照说明了一切。

IIS显示WCF网站

我知道在所引用的SO文章中,该人员坚持认为问题出在IIS中,而事实并非如此,但是我的问题肯定是这样。 我只是又一次尝试了basicHttpBinding

浏览器页面显示此站点已禁用消息的元数据

在asp.net论坛上的这个问题也很有趣。 我本能地将App.config重命名为Web.config并重建了DLL。 IIS不会读取“ App.config”。

思考?

最后引用的文章指出了问题,我的猜想是正确的。 我在写的很好时就把这个问题留在这里,但更重要的是,没有说明重要的事实。

Visual StudioC#没有嵌入Web.config,或者IIS没有从DLL中提取文件。 我读过的所有文章都说要写一个SVC文件,将DLL放在bin文件中,但是都忽略了两个关键信息。

  1. App.config复制到“ Web.config”。

  2. Web.config的副本放置在与SVC文件相同的文件夹中。

无需刷新IIS中的网站,但是必须刷新浏览器页面。

我希望这个答案对某人有帮助,因为我确实受了苦,几乎没有得到。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM