为 RESTful WCF 配置 SSL 绑定。如何?

2023-12-07

我当前的配置如下所示:

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <standardEndpoints>
      <webHttpEndpoint>
        <!--Set limit to 5 megabytes-->
        <standardEndpoint helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="5242880">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />

        </standardEndpoint>

      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>

当我有时这有效http and https绑定都为我的网站配置。

我通过 https 连接到服务,一切正常。

现在我想删除http完全绑定到IIS。我开始收到这样的错误:

找不到与方案 http 匹配的基地址 具有绑定 WebHttpBinding 的端点。注册基地址方案 是[https]。

[InvalidOperationException:找不到匹配的基地址 具有绑定 WebHttpBinding 的端点的方案 http。挂号的 基地址方案是[https]。]
System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri、Binding 绑定、UriSchemeKeyedCollection 基本地址)+16582113
System.ServiceModel.Description.ConfigLoader.ConfigureEndpointAddress(ServiceEndpointElement serviceEndpointElement、ServiceHostBase 主机、ServiceEndpoint 端点)+117
System.ServiceModel.Description.ConfigLoader.ConfigureEndpoint(StandardEndpointElement 标准端点元素、服务端点元素 serviceEndpointElement、ContextInformation 上下文、ServiceHostBase 主机、ServiceDescription 描述、ServiceEndpoint& 端点、 布尔省略SettingEndpointAddress) +937
System.ServiceModel.Description.ConfigLoader.LookupEndpoint(ServiceEndpointElement serviceEndpointElement、ContextInformation 上下文、ServiceHostBase 主机,ServiceDescription 描述,布尔值 省略设置端点地址)+8728167
System.ServiceModel.Web.WebServiceHost.AddAutomaticWebHttpBindingEndpoints(ServiceHost 主机,IDictionary`2implementedContracts,字符串 multipleContractsErrorMessage,字符串 standardEndpointKind) +982
System.ServiceModel.Web.WebServiceHost.OnOpening() +311
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan 超时)+612
System.ServiceModel.HostingManager.ActivateService(字符串 标准化虚拟路径)+255
System.ServiceModel.HostingManager.EnsureServiceAvailable(字符串 标准化虚拟路径)+1172

[ServiceActivationException:服务“/DEMO/mobile”不能 由于编译期间出现异常而激活。例外情况 消息是:找不到与方案 http 匹配的基地址 具有绑定 WebHttpBinding 的端点。注册基地址 方案是 [https]..] System.Runtime.AsyncResult.End(IAsyncResult 结果)+901424
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult 结果)+178702
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +136

我找到了一堆 WCF 示例,但 REST WCF 在配置方面看起来有所不同,我想了解why它很痛苦。从我的配置来看 - 它根本不应该通过 SSL 工作,但它does当 https 绑定存在时工作..


按照错误提示执行操作...修复您的绑定

 <services>
      <service name="service" behaviorConfiguration="serviceBehavior">
        <endpoint address="" binding="webHttpBinding"
              bindingConfiguration="https"
contract="IContract" behaviorConfiguration="endpointBehavior">
        </endpoint>
      </service>
    </services> 

<bindings>
 <webHttpBinding>
  <binding name="https" maxReceivedMessageSize="65536">
    <security mode="Transport" />
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />

  </binding>
 </webHttpBinding>
</bindings>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为 RESTful WCF 配置 SSL 绑定。如何? 的相关文章

随机推荐