2012-03-03 43 views
4

我现在的配置看起来像这样:为RESTful WCF配置SSL绑定。怎么样?

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

这工作时,我有httphttps绑定都配置为我的网站。

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

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

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

[InvalidOperationException:无法找到匹配 scheme http的基地址,该地址与具有绑定WebHttpBinding的端点匹配。注册 基址方案是[HTTPS]。]
System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(URI relativeOrAbsoluteUri,装订装订,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

[ServiceActivationException:由于编译期间发生异常,服务'/ DEMO/mobile'不能为 。 消息的例外是:无法找到与绑定WebHttpBinding的端点匹配的http http: 的基址。注册的基地址 计划是[https] ..] System.Runtime.AsyncResult.End(IAsyncResult result)+901424
System.ServiceModel.Activation.HostedHttpRequestAsyncResult。完(IAsyncResult的 结果)178702
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult的 AR)+136

我发现一堆样品进行WCF但REST WCF看起来配置方面的不同,我想了解为什么它compains。从我的配置看起来 - 它不应该通过SSL在所有的工作,但它确实工作 HTTPS时,结合本..

+0

如果你想删除HTTP上的IIS绑定,只要右击网站选择编辑绑定选项,并删除绑定列表http协议。这应该足够了 – Rajesh 2012-03-05 09:36:39

+0

不。如果我这样做 - 我发现我发布的确切错误。 – katit 2012-03-05 14:14:21

+0

你想用http访问url吗? – Rajesh 2012-03-05 14:18:42

回答

3

不要错误说什么......解决您的结合

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

这实际上并不是问题的解决方案,因为原始的海报正在使用标准端点,并且此答案需要明确的端点。对于可以轻松切换到显式端点的人,我想这是可以的。但我不能,所以我没有答案。 – PeteAC 2017-01-03 16:45:42

0

试试这个

<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> 
    <security mode="Transport" /> 
    </webHttpEndpoint> 
</standardEndpoints> 
</system.serviceModel> 
+0

元素'webHttpEndpoint'具有无效的子元素'security'。预期可能的元素列表:'standardEndpoint,remove,clear'。 – katit 2012-03-07 17:37:54

1

接受的答案对我无效,因为我需要保留我的标准端点元素。我能删除我的HTTP绑定,只留在IIS中的HTTPS结合通过添加<webHttpBinding>部分,我的web.config

确保没有设置在<binding>name属性,否则将无法正常工作我的web.config的

相关部分:

<system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
    <bindings> 
     <webHttpBinding> 
     <binding> 
      <!-- Comment out the following line if HTTP is used. If HTTPS is used, leave it enabled --> 
      <security mode="Transport"/> 
     </binding> 
     </webHttpBinding> 
    </bindings> 
    <standardEndpoints> 
     <webHttpEndpoint> 
     <standardEndpoint name="" helpEnabled="false" automaticFormatSelectionEnabled="true"/> 
     </webHttpEndpoint> 
    </standardEndpoints> 
    </system.serviceModel>