我有一个简单的 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/