如何允许Web服务同时提供请求http和https? [英] How to allow web service to serve both request http and https?
问题描述
<pre lang="XML"> <system.serviceModel>
<services>
<service behaviorConfiguration="Complete_Html5.CompleteService.CompleteServiceAspNetAjaxBehavior" name="Complete_Html5.CompleteService.Complete">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Complete" contract="Complete_Html5.CompleteService.Complete" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<service name="Complete_Html5.Service1" behaviorConfiguration="Complete_Html5.Service1ServiceAspNetAjaxBehavior">
<endpoint address="" binding="basicHttpBinding" contract="Complete_Html5.Service1" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="Complete_Html5.Service1AspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="Complete_Html5.CompleteService.CompleteServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Complete_Html5.CompleteService.CompleteServiceAspNetAjaxBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="Complete_Html5.Service1ServiceAspNetAjaxBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Complete" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="10485760" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="BasicHttpBinding_Complete1" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="BasicHttpBinding_Service1" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="10485760" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="BasicHttpBinding_Service11" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.examplete.com:83/CompleteService/Complete.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Complete" contract="Complete_Html5.CompleteService.Complete" name="BasicHttpBinding_Complete" />
<endpoint address="http://www.examplete.com:83/CompleteService/Complete.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Complete1" contract="PMCService.Complete" name="BasicHttpBinding_Complete1" />
<endpoint address="http://www.examplete.com:83/Service1.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service1" contract="ReportService.Service1" name="BasicHttpBinding_Service1" />
<endpoint address="http://www.examplete.com:83/Service1.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service11" contract="ReportService.Service1" name="BasicHttpBinding_Service11" />
</client>
</system.serviceModel>
Above is the `service` setting in `web.config` what changes I have to make so that I could use both hits `http` and `https` while accessing `website`??
What I have tried:
We have added ssl certificate to server and have unchecked `required ssl` from website `ssl` certificate setting.
It it working fine `http` but when hits come is website is with `https` it’s throwing error as:
> The provided URI scheme `https` is invalid; Expected `http`. Parameter
> name: via.
How to solve this so that allow both hits `http` and `https`?
> This is specially when we calling web service method.!
Have tried by adding `httpsGetEnabled=\"true\"` in serviceMetadata element but still not working..!
What I have tried:
We have added ssl certificate to server and have unchecked `required ssl` from website `ssl` certificate setting.
It it working fine `http` but when hits come is website is with `https` it's throwing error as:
> The provided URI scheme `https` is invalid; Expected `http`. Parameter
> name: via.
How to solve this so that allow both hits `http` and `https`?
> This is specially when we calling web service method.!
Have tried by adding `httpsGetEnabled="true"` in serviceMetadata element but still not working..!
推荐答案
The ideal solution is to define two endpoints, one for HTTP and another for HTTPS.
You also need to update/define configurations accordingly for both client and service section.
The ideal solution is to define two endpoints, one for HTTP and another for HTTPS.
You also need to update/define configurations accordingly for both client and service section.
这篇关于如何允许Web服务同时提供请求http和https?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!