我当前的配置如下:
<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
绑定时,此功能正常工作。
我通过https连接到服务,一切都很好。
现在我想完全删除IIS上的http
绑定。我开始得到这样的错误:
无法找到与方案http匹配的基地址 绑定WebHttpBinding的端点。注册的基地址方案 是[https]。
[InvalidOperationException:找不到匹配的基址 具有绑定WebHttpBinding的端点的scheme http。注册 基地址方案是[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&amp;端点, Boolean omitSettingEndpointAddress)+937
System.ServiceModel.Description.ConfigLoader.LookupEndpoint(ServiceEndpointElement serviceEndpointElement,ContextInformation上下文,ServiceHostBase 主机,ServiceDescription描述,布尔值 omitSettingEndpointAddress)+8728167
System.ServiceModel.Web.WebServiceHost.AddAutomaticWebHttpBindingEndpoints(ServiceHost的 host,IDictionary`2已实现的字符串,字符串 multipleContractsErrorMessage,String standardEndpointKind)+982
System.ServiceModel.Web.WebServiceHost.OnOpening()+ 311 11 System.ServiceModel.Channels.CommunicationObject.Open(时间跨度 超时)+612
System.ServiceModel.HostingManager.ActivateService(字符串 normalizedVirtualPath)+255
System.ServiceModel.HostingManager.EnsureServiceAvailable(字符串 normalizedVirtualPath)+1172[ServiceActivationException:服务'/ DEMO / mobile'不能 由于编译期间的异常而激活。例外 消息是:找不到与scheme http匹配的基址 具有绑定WebHttpBinding的端点。注册基地址 scheme是[https] ..] System.Runtime.AsyncResult.End(IAsyncResult 结果)+901424
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult的 结果)+178702
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult的 ar)+136
我为WCF找到了大量样本,但是REST WCF在配置方面看起来不同,我想了解为什么它会重复。从我的配置的外观 - 它应该不适用于SSL,但当https绑定存在时 工作..
答案 0 :(得分: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>
答案 1 :(得分:1)
接受的答案对我不起作用,因为我需要保留我的标准端点元素。我能够删除我的http绑定,只通过在我的Web.config
中添加<webHttpBinding>
部分来保留IIS中的https绑定
请务必不要在name
上设置<binding>
属性,否则无法使用
我的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>
答案 2 :(得分: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>