gpt4 book ai didi

wcf - 更改 WCF 服务以要求 SSL

转载 作者:太空宇宙 更新时间:2023-11-03 13:01:51 24 4
gpt4 key购买 nike

我有一个在 http 绑定(bind)上运行良好的 WCF 服务。我已尝试将其更新为使用 SSL,但出现以下错误:

“找不到与具有绑定(bind) WSHttpBinding 的端点的方案 http 相匹配的基地址。注册的基地址方案是 [https]。”

只有当我在 IIS 7.5 中将站点设置为“需要 SSL”时,如果我取消选中它,它才能正常工作,才会发生这种情况。

这是我的配置

<system.serviceModel>    
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior" >
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="WcfService1.Service1">
<host>
<baseAddresses>
<add baseAddress="http://localhost/WcfService1/"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration=""
name="wsHttpEndpoint" contract="WcfService1.IService1" />
<endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration=""
name="MexHttpsBindingEndpoint" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

我已经尝试了各种方法,但似乎没有任何帮助,非常感谢任何帮助!

最佳答案

修改绑定(bind)配置:

<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
<security mode="Transport" />
</binding>
</wsHttpBinding>
</bindings>

并通过将其 bindingConfiguration 属性设置为配置名称来在您的 endpoint 中引用该配置。

<endpoint address="" binding="wsHttpBinding" 
bindingConfiguration="wsHttpEndpointBinding"
name="wsHttpEndpoint" contract="WcfService1.IService1" />

您也可以删除带有基地址的host部分,因为在IIS中托管时不使用它。

关于wcf - 更改 WCF 服务以要求 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5258309/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com