在IIS中发布Web服务时出错 - 无法找到基...绑定WebHttpBinding。注册的基地址方案是[https]

时间:2017-05-31 20:53:01

标签: web-services wcf web-config

我正在尝试发布在VS2015中创建和发布的Web服务。当我在IIS中发布它时,我有以下错误: 找不到与绑定WebHttpBinding的端点的scheme http匹配的基址。注册的基地址方案为[https] 我看了很多关于它的帖子,我试图改变我的IIS和我的web.config没有成功。

我在IIS中使用自签名证书配置了https网站。它工作正常,但是当我尝试访问web服务时,我得到了上面描述的错误。如果我在http网站上使用这个web服务,它没有问题。

我的web.config

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation targetFramework="4.6" />
    <httpRuntime targetFramework="4.6" />
    <customErrors mode="Off"/>  
  </system.web>
  <system.serviceModel>
    <!--CONFIGURAÇÃO DO SERVIÇO-->
    <services>      
      <service name="ServicoRest.ServiceGestorWMS">
        <endpoint address="../ServiceGestorWMS.svc" binding="webHttpBinding" contract="ServicoRest.IServiceGestorWMS" behaviorConfiguration="webBehaviour" />
        <endpoint address="mex"  
                  binding="mexHttpsBinding"  
                  contract="IMetadataExchange" />  
      </service>
    </services>
     <bindings>
   <webHttpBinding>
    <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows"/>
      </security>
    </binding>
    <binding name="webHttpsBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <security mode="Transport">
        <transport clientCredentialType="Windows"/>
      </security>
    </binding>
  </webHttpBinding>
 </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <!--CONFIGURAÇÃO DO SERVIÇO-->
      <endpointBehaviors>
        <behavior name="webBehaviour">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <!--SE VOCÊ PRECISAR ACESSAR O SERVIÇO DE OUTRO DOMÍNIO VIA JAVASCRIPT VOCÊ DEVE INFORMAR O BLOCO DE CÓDIGO ABAIXO -->
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type, Accept" />
        <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
      </customHeaders>
    </httpProtocol>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true" />
  </system.webServer>
  <connectionStrings>
    <add name="" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=;initial catalog=;persist security info=True;user id=sa;password=;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
</configuration>
<!--ProjectGuid: {D84BF523-87CA-4D7D-90AE-CEE789984582}-->

1 个答案:

答案 0 :(得分:0)

墨菲

您似乎没有设置绑定。如果要支持webHttpBinding的HTTP和HTTPS,则需要类似web.config中的代码:

<webHttpBinding>
    <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows"/>
      </security>
    </binding>
    <binding name="webHttpsBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <security mode="Transport">
        <transport clientCredentialType="Windows"/>
      </security>
    </binding>
  </webHttpBinding>