简体   繁体   English

在 IIS 发布 WCF 作为 https 出现错误

[英]Publishing WCF at IIS as https getting error

We created a WCF service and able to consume locally.我们创建了一个 WCF 服务并能够在本地消费。 When published it at IIS and consume it as https its giving below error当在 IIS 发布它并将其作为 https 使用时,它给出以下错误

Could not find a base address that matches scheme http for the endpoint with binding WSHttpBinding.找不到与绑定 WSHttpBinding 的端点的方案 http 匹配的基地址。 Registered base address schemes are [https].注册的基地址方案是 [https]。

Config file配置文件

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

Buddy, this is because the service endpoint with Wshttpbinding requires an HTTP base address.哥们,这是因为带有 Wshttpbinding 的服务端点需要一个 HTTP 基地址。 By default, it doesn't support Https .默认情况下,它不支持Https We could publish the service endpoint over Https protocol, it requires that the Wshttpbinding enable transport security mode.我们可以通过 Https 协议发布服务端点,它要求Wshttpbinding启用传输安全模式。 Please refer to the below configuration.请参考以下配置。

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

Feel free to let me know if the problem still exists.如果问题仍然存在,请随时告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM