【发布时间】:2011-09-05 23:00:36
【问题描述】:
我有一个带有自定义绑定的 WCF 服务,它在 http 或 https 上都可以正常工作。但我完全不知道如何让它在 http 和 https 上都可用?
还有可能吗?
这是我在 web.config 中的配置。
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="customBinding0">
<binaryMessageEncoding />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<services>
<service name="MyWCFService">
<endpoint address="" binding="customBinding" bindingConfiguration="customBinding0"
contract="MyWCFService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
谢谢
【问题讨论】:
-
为 http 添加一个端点,为 https 添加另一个端点将解决您的问题。
-
我已添加作为答案,但仍然收到类似这样的错误“找不到与具有绑定 CustomBinding 的端点的方案 https 匹配的基地址。注册的基地址方案是 [http]。 "
-
您需要在端点中提供两个不同的地址,因为两个端点不能共享相同的地址。
-
你能解决它吗?如果是的话,你能发布答案吗?
-
端点中两个不同地址的示例?
标签: wcf http https custom-binding