[英]Configure SSL binding for RESTful WCF. How?
我當前的配置如下:
<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
綁定。 我開始得到這樣的錯誤:
找不到與綁定WebHttpBinding的端點的scheme http匹配的基址。 注冊的基地址方案是[https]。
[InvalidOperationException:找不到與綁定WebHttpBinding的端點的scheme http匹配的基址。 注冊的基地址方案是[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[ServiceActivationException:由於編譯期間發生異常,無法激活服務'/ DEMO / mobile'。 異常消息是:找不到與綁定WebHttpBinding的端點的scheme http匹配的基址。 注冊的基地址方案是[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綁定存在時確實有效..
做錯誤說的...修復你的綁定
<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>
接受的答案對我不起作用,因為我需要保留我的標准端點元素。 我能夠刪除我的http綁定,只通過在我的Web.config中添加<webHttpBinding>
部分將IIS中的https綁定保留下來
確保不在<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>
試試這個
<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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.