2011-09-12 56 views
2

我在使用SSL和WCF獲取Web服務時遇到問題。WCF和SSL問題

如果我在IIS中選中「要求SSL」,然後seeting我得到這個錯誤:

WebHost failed to process a request.

Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/36097441 Exception: System.ServiceModel.ServiceActivationException: The service '/' cannot be activated due to an exception during compilation. The exception message is: Service 'ISS.MS.WebServices.MessageDispatch.MessageDispatchWebService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.. ---> System.InvalidOperationException: Service 'ISS.MS.WebServices.MessageDispatch.MessageDispatchWebService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

但是如果我取消它,頁面加載在瀏覽器不錯,但後來我得到這個錯誤當我嘗試調用它時,我會嘗試使用 。

Service 'ISS.MS.WebServices.MessageDispatch.MessageDispatchWebService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

這是配置:

<system.serviceModel> 
    <services> 
     <service name="ISS.MS.WebServices.MessageDispatchWcfService"> 
      <endpoint 
       address="" 
       binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_MS2" 
       contract="ISS.MS.WebServices.IMessageDispatchWcfService" /> 
      <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior> 
       <serviceDebug includeExceptionDetailInFaults="False" /> 
       <serviceMetadata httpsGetEnabled="true"/> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 

    <bindings> 
     <basicHttpBinding> 
      <binding name="basicHttpBinding_MS2" > 
       <readerQuotas maxStringContentLength="1048576" /> 
       <security mode="Transport"> 
       </security> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"> 
    </serviceHostingEnvironment> 
</system.serviceModel> 

我能得到它的工作完全正常使用HTTP,但是HTTPS的不起作用。

我猜測它的IIS設置或WCF配置問題?

回答

3

我想通了,服務和合同的名稱是不正確的......多麼尷尬。

任何人都知道爲什麼它仍然可以通過HTTP工作,即使它們不正確?

+1

謝謝。這剛剛結束了大約8個小時的調試。 –

0

(關於「multipleSiteBindingsEnabled」):要爲服務啓用每個站點的多個IIS綁定,請將此屬性設置爲true。注意多個站點綁定僅支持HTTP協議。

裁判:http://msdn.microsoft.com/en-us/library/system.servicemodel.configuration.servicehostingenvironmentsection.multiplesitebindingsenabled.aspx

試試這個

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false"> 
</serviceHostingEnvironment>