在IIS上将WCF发布为https收到错误

我们创建了WCF服务,并且能够在本地使用。 当它在IIS上发布并以https形式使用时,出现以下错误

  

找不到与方案http匹配的基地址   具有绑定WSHttpBinding的端点。注册基址方案   是[https]。

配置文件

<?xml version="1.0"?> <configuration>

  <appSettings>
    <add key="aspnet:UsetaskFriendlySynchronizationContext" value="true" />   </appSettings>   <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpruntime targetFramework="4.5"/>   </system.web>   <system.serviceModel>
    <services>
      <service name="WCF_Portal_Service.Portal">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration=""
          contract="WCF_Portal_Service.IPortal" />
      </service>
    </services>
    <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>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <servicehostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />   </system.serviceModel>   <system.webServer>
    <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>

</configuration>
v0zhang 回答:在IIS上将WCF发布为https收到错误

伙计,这是因为具有Wshttpbinding的服务端点需要HTTP基址。默认情况下,它不支持Https。我们可以通过Https协议发布服务端点,它要求Wshttpbinding启用传输安全模式。 请参考以下配置。

<system.serviceModel>
    <services>
      <service name="WcfService3.Service1">
        <endpoint address="" binding="wsHttpBinding" contract="WcfService3.IService1" bindingConfiguration="mybinding"></endpoint>
        <!--Add an extra endpoint to exchange the service metadata-->
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"></endpoint>
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="mybinding">
          <security mode="Transport">
            <transport clientCredentialType="None"></transport>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
  </system.serviceModel>

请随时让我知道问题是否仍然存在。

本文链接:https://www.f2er.com/3112851.html

大家都在问