WCF: не удалось найти базовый адрес, который соответствует схеме http для конечной точки с привязкой WebHttpBinding.Схемы зарегистрированных базовых адресов: [https] - PullRequest
0 голосов
/ 05 июня 2018

У меня есть служба wcf, созданная на платформе 4. и размещенная в IIS с использованием https.

Ниже приведен мой файл конфигурации и ошибка, которую я получил

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

1 Ответ

0 голосов
/ 05 июня 2018

Выходя из положения здесь ...

На основании вашего файла конфигурации и полученного сообщения об ошибке, вам кажется, что вам нужно установить для security режима webHttpBinding значение Transport.

Из документации видно, что по умолчанию свойство security для WebHttpBinding равно None.

Чтобы использовать протокол HTTPS, вам необходимо установить для режима security значение Transport

. Конфигурация для вашей привязки WebHttpBinding будет следующей:

<webHttpBinding>
     <binding name="LargeWeb" maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000" maxBufferSize="20000000">
         <readerQuotas maxArrayLength="20000000" maxBytesPerRead="20000000" maxDepth="32" maxNameTableCharCount="20000000" maxStringContentLength="20000000" />
         <security mode="Transport">
     </binding>
</webHttpBinding>
...