wcf - 一个监听多个地址的 WCF 服务(仅限配置)
问题描述
我有一个托管 WCF 服务的现有 Windows 服务(所以没有 IIS)。
此时它正在监听一个地址:http://xxx/service.svc。
现在我想让它也听第二个地址:http://yyy/service.svc。
我只能修改配置,不能修改源。该服务在 .NET Framework 4.5.2 下运行。
我的配置:
<services>
<service behaviorConfiguration="All" name="MyNamespace.MyService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBindingConfig" contract="MyNamespace.IMyService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://xxx/service.svc"/>
</baseAddresses>
</host>
</service>
</services>
到目前为止我已经尝试过:
- 添加了一个额外的基地址。然后我得到一个例外:
This collection already contains an address with scheme http.
- 复制服务元素并修改基地址。例外:
A child element named 'service' with same key already exists at the same configuration scope.
- 如果我更改这两个服务的名称:
Service 'MyNamespace.MyService' has zero application (non-infrastructure) endpoints.
- 如果已阅读并尝试过
serviceHostingEnvironment
(如WCF 服务启动错误“此集合已包含带有方案 http 的地址”中所建议的那样)但仅添加该片段,则无济于事。也许这是向前迈出了半步,但我需要该解决方案的后半部分。
解决方案
推荐阅读
- google-maps - 如何将项目和 API KEY 从开发人员仪表板移动到客户新帐户
- python - FFT 的最佳方法 - 最大。值 FFT - Python
- javascript - 通过 javascript 获取当前 URL 地址
- ios - Swift:UIView 中的 applicationDidBecomeActive?
- json - 什么决定(如何配置)php PDO 驱动程序对日期和时间戳字段的值使用什么格式字符串?
- typescript - 如何在 scss 中访问 typescript 变量?(Typescript/scss)
- javascript - 单击选择按钮上的选项时如何显示图像?
- android - 如何将自定义 Groovy 任务转换为自定义 Kotlin 任务?
- scala - 地图导出到 CSV 文件
- mysql - 错误:mysql gem 的捆绑安装失败