我使用框架4构建了wvf服务,并使用https托管到IIS。
下面是我的配置文件和我得到的错误
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime />
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="WebService.Service1">
<endpoint address="" binding="webHttpBinding" contract="WebService.IService1" bindingConfiguration="LargeWeb" behaviorConfiguration="webBehavior" />
<endpoint address="h" binding="basicHttpBinding" contract="WebService.IService1" bindingConfiguration="" behaviorConfiguration="" />
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="secureHttpBinding" contract="WebService.IService1"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="LargeWeb" maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000" maxBufferSize="20000000">
<readerQuotas maxArrayLength="20000000" maxBytesPerRead="20000000" maxDepth="32" maxNameTableCharCount="20000000" maxStringContentLength="20000000" />
</binding>
</webHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="false" />
</system.webServer>
</configuration>
错误返回
Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [https].
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [https].
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
答案 0 :(得分:0)
在这里走出困境......
根据您的配置文件和您收到的错误消息,您似乎需要将security
的{{1}}模式设置为webHttpBinding
。
您可以从文档中看到,默认情况下WebHttpBinding上的Transport
属性为None。
要使用HTTPS协议,您需要将security
模式设置为security
WebHttpBinding的配置如下:
Transport