配置SSL REST风格的WCF绑定。怎么样? [英] Configure SSL binding for RESTful WCF. How?

查看:181
本文介绍了配置SSL REST风格的WCF绑定。怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前的配置看起来像这样:

My current config looks like so:

<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 HTTPS 绑定均配置为我的网站

This works when I have http and https bindings both configured for my website.

我连接通过HTTPS来服务,一切的伟大工程。

I connect to service via https and everything works great.

现在我想删除 HTTP 在IIS上结合完全。我开始变得像这样的错误:

Now I want to remove http binding on IIS completely. And I started to get error like this:

无法找到的匹配计划http的基址   端点绑定的WebHttpBinding。注册的基址方案   在[HTTPS]。

Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [https].

[InvalidOperationException异常:找不到匹配的基址   计划http用于绑定的WebHttpBinding端点。注册   基址方案是[HTTPS]]
  System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(URI   relativeOrAbsoluteUri,约束力181,UriSchemeKeyedCollection   baseAddresses)16582113
  System.ServiceModel.Description.ConfigLoader.ConfigureEndpointAddress(ServiceEndpointElement   serviceEndpointElement,ServiceHostBase主机,ServiceEndpoint   端点)+117
  System.ServiceModel.Description.ConfigLoader.ConfigureEndpoint(StandardEndpointElement   standardEndpointElement,ServiceEndpointElement   serviceEndpointElement,ContextInformation背景下,ServiceHostBase   主机,ServiceDescription描述,ServiceEndpoint和放大器;端点,   布尔omitSettingEndpointAddress)937
  System.ServiceModel.Description.ConfigLoader.LookupEndpoint(ServiceEndpointElement   serviceEndpointElement,ContextInformation背景下,ServiceHostBase   主机,ServiceDescription描述,布尔   omitSettingEndpointAddress)8728167
  System.ServiceModel.Web.WebServiceHost.AddAutomaticWebHttpBindingEndpoints(ServiceHost的   主机,IDictionary`2 implementedContracts,字符串   multipleContractsErrorMessage,串standardEndpointKind)982
  System.ServiceModel.Web.WebServiceHost.OnOpening()311
  System.ServiceModel.Channels.CommunicationObject.Open(时间跨度   超时)+612
  System.ServiceModel.HostingManager.ActivateService(字符串   normalizedVirtualPath)+255
  System.ServiceModel.HostingManager.EnsureServiceAvailable(字符串   normalizedVirtualPath)1172

[InvalidOperationException: Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [https].]
System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses) +16582113
System.ServiceModel.Description.ConfigLoader.ConfigureEndpointAddress(ServiceEndpointElement serviceEndpointElement, ServiceHostBase host, ServiceEndpoint endpoint) +117
System.ServiceModel.Description.ConfigLoader.ConfigureEndpoint(StandardEndpointElement standardEndpointElement, ServiceEndpointElement serviceEndpointElement, ContextInformation context, ServiceHostBase host, ServiceDescription description, ServiceEndpoint& endpoint, Boolean omitSettingEndpointAddress) +937
System.ServiceModel.Description.ConfigLoader.LookupEndpoint(ServiceEndpointElement serviceEndpointElement, ContextInformation context, ServiceHostBase host, ServiceDescription description, Boolean omitSettingEndpointAddress) +8728167
System.ServiceModel.Web.WebServiceHost.AddAutomaticWebHttpBindingEndpoints(ServiceHost host, IDictionary`2 implementedContracts, String multipleContractsErrorMessage, String standardEndpointKind) +982
System.ServiceModel.Web.WebServiceHost.OnOpening() +311
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +612
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +255
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172

[ServiceActivati​​onException:服务/ DEMO /移动不能   在编译期间,由于异常激活。唯一的例外   消息:无法找到的匹配计划http的基址   端点与绑定的WebHttpBinding。注册的基址   方案是[HTTPS] ..] System.Runtime.AsyncResult.End(IAsyncResult的   结果)901424
  System.ServiceModel.Activati​​on.HostedHtt prequestAsyncResult.End(IAsyncResult的   结果)178702
  System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult的   AR)+136

[ServiceActivationException: The service '/DEMO/mobile' cannot be activated due to an exception during compilation. The exception message is: Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [https]..] System.Runtime.AsyncResult.End(IAsyncResult result) +901424
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178702
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +136

我发现一堆样品WCF,但REST WCF看上去就配置侧不同,我想了解的为什么的是孔潘。从我的配置看起来 - 它不应该SSL工作在所有,但它的确实的工作的时候HTTPS绑定present ..

I found bunch of samples for WCF but REST WCF looks different on config side and I want to understand why it compains. From looks of my config - it should not work over SSL at all but it does work when https binding present..

推荐答案

做了哪些错误说...解决您的结合

Do what the error says... fix your binding

 <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>

这篇关于配置SSL REST风格的WCF绑定。怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆