gpt4 book ai didi

c# - WCF 服务的 basicHttpBinding 上的 HTTPS

转载 作者:可可西里 更新时间:2023-11-01 09:16:27 26 4
gpt4 key购买 nike

我正在使用 IIS 7。它启用了 HTTPS 绑定(bind),端口号为 443。我在网站下有一个 WCF 服务作为应用程序。我正在尝试基于 http://msdn.microsoft.com/en-us/library/ms729700.aspx 向服务(使用 basicHttpBinding)引入 HTTPS 安全性

我收到以下错误 - “提供的 URI 方案‘https’无效;预期'http'。”。当我检查事件日志时,它具有如下堆栈跟踪:

Stack Trace :    at System.ServiceModel.Channels.TransportChannelFactory`1.ValidateScheme(Uri via)

at System.ServiceModel.Channels.HttpChannelFactory.ValidateCreateChannelParameters(EndpointAddress remoteAddress, Uri via)

要使其在带有 basicHttpBinding 的 HTTPS 上工作需要进行哪些更改?

注意:证书是使用 IIS 7 中的“创建自签名证书”创建的。

 <system.serviceModel>

<behaviors>
<serviceBehaviors>
<behavior name="serviceFaultBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>

<services>
<service name="Business.TV.Clearance.Services.ServiceHandler"
behaviorConfiguration="serviceFaultBehavior">
<endpoint address=""
binding="basicHttpBinding"
contract="Business.TV.Clearance.Services.IServiceHandler"
bindingConfiguration="httpBinding">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>

  <bindings>
<basicHttpBinding>

<binding name="httpBinding"
maxReceivedMessageSize="2000000"
maxBufferSize="2000000">

<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>


<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

<extensions>
<behaviorExtensions>
<add name="serviceFaultBehavior"
type="Business.TV.Clearance.Services.ServiceFaultBehaviorExtensionElement,Business.TV.Clearance.Services, Version=1.0.0.0, Culture=neutral"/>
</behaviorExtensions>
</extensions>

</system.serviceModel>

最佳答案

你需要改变:

<serviceMetadata httpGetEnabled="true" />

到:

<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />

关于c# - WCF 服务的 basicHttpBinding 上的 HTTPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8337978/

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