2015-02-24 39 views
0

我試圖通過HTTP和HTTPS主辦的WCF服務,並使用以下配置:我想在兩個端點舉辦一個WCF服務,HTTP和HTTPS

<system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_ITestService"> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" 
       realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     <binding name="BasicHttpsBinding_ITestService"> 
      <security mode="Transport"> 
      <transport clientCredentialType="None" proxyCredentialType="None" /> 
      <message /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
     <service name="TestService" behaviorConfiguration="TestServiceBehaviour"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8081/"/> 
      <add baseAddress="https://localhost:8083/"/> 
      </baseAddresses> 
     </host> 
     <endpoint address="" 
      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITestService" 
      contract="ITestService" name="BasicHttpsBinding_ITestService" /> 
     <endpoint address="" 
      binding="basicHttpBinding" bindingConfiguration="BasicHttpsBinding_ITestService" 
      contract="ITestService" name="BasicHttpsBinding_ITestService" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="TestServiceBehaviour"> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

</configuration> 

但我收到以下錯誤: 無法找到與具有綁定BasicHttpBinding的端點匹配scheme https的基地址。註冊的基地址方案是[http]。

需要一個解決方案,因爲我已經爲http和https定義了基地址和綁定。

謝謝。

回答

0

試試這個

<endpoint address="" 
      binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_ITestService" 
      contract="ITestService" name="BasicHttpsBinding_ITestService"/> 
<endpoint address="" 
      binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpsBinding_ITestService" 
      contract="ITestService" name="BasicHttpsBinding_ITestService"/> 
<endpoint address="mex" 
     binding="mexHttpsBinding" 
     contract="IMetadataExchange" /> 
+0

得到了與MexExchangeHttpsBinding相同的錯誤:無法找到與具有綁定MetadataExchangeHttpsBinding的端點匹配scheme https的基地址。註冊的基地址方案是[http]。 – user2156035 2015-02-24 14:17:17

+0

嘗試評論主機部分,並檢查我的情況我在開發過程中刪除主機 – 2015-02-24 14:28:54

0

我沒有啓用HTTPS的IIS服務器上的約束力,並嘗試使用https協議託管的服務。創建證書並在IIS服務器上啓用https綁定可解決此問題。 :)

相關問題