WCF 服务 - 最低要求的 web.config?

标签 wcf .net-3.5 web-config

我有一个简单的 WCF 服务(在 IIS 中作为自己的站点托管)。它最初是针对 .NET 4 开发的,但我最近发现它需要降级到 .NET 3.5。

我从来没有接触过 web.config 文件,它只是工作。现在我已将项目从 .NET 4 更改回 3.5,我遇到了配置错误。第一个是关于 multipleSiteBindingsEnabled 未被识别 - 快速搜索告诉我这是 .NET 4 中的新内容,因此我将其删除。现在我得到的错误是:

Service 'MyService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

我只想让服务响应,以便我可以测试触发它的东西。将使用该服务的系统还不存在(它目前正在由政府部门开发),因此一旦接近完成,我们将担心将其投入生产等所需的配置。我需要在 web.config 中进行测试的最低配置?

最佳答案

您的服务的 web.config 文件中通常需要这些基本节点。 当然 binding types/dedub config/etc 只是为了测试。 您需要根据自己的需要对其进行微调

<system.serviceModel>
        <services>
            <service name="A.B.C.D" behaviorConfiguration="returnFaults">
                <endpoint contract="A.B.C.ID" binding="basicHttpBinding" address=""/>
            </service>
        </services>
        <bindings>
            <basicHttpBinding>
                <binding name="HttpBinding" maxReceivedMessageSize="2097152">
                </binding>
            </basicHttpBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="returnFaults">
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                    <serviceMetadata httpGetEnabled="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>

关于WCF 服务 - 最低要求的 web.config?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4252803/

相关文章:

c# - WCF 应用端点

c# - 哪种设计更适合具有大量数据共享的客户端/服务器项目

c# - 如何实现接口(interface)返回带有空方法体的 IAsyncResult

c# - 相对 URI 不支持此操作,浏览 SVC 服务时出错

linq - 缺少命名空间,LINQ 可以在 Web 应用程序中运行,但不能在网站中运行!

c# - 如何在 .NET C# 3.5 中循环访问 "set"枚举

c# - 如何修改 CompositeControl 的 ClientId,消除所述 ID 的呈现,而不影响 ChildControls?

c# - 如何让NLog写入数据库

asp.net - 重写 ASP URL 并获得重定向循环

asp.net - 使用连接字符串 configSource 属性以及 Azure 应用服务环境连接字符串时,部署后启动失败