2012-02-24 30 views
0

我已經編寫了我的第一個WCF Web服務,該服務在我自己的本地測試Web服務器上運行良好,但是當我將它部署到IIS時出現錯誤。無法使用Windows驗證獲得WCF Web服務

我們的IIS服務器使用集成身份驗證,而且不是允許匿名訪問。從what I've read,我需要將綁定上的安全模式設置爲TransportCredentialOnly。在web.config整款:

<system.serviceModel> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="VZW.TrainingPortfolioManager.Website.TPMAspNetAjaxBehavior"> 
      <enableWebScript /> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    <services> 
     <service name="VZW.TrainingPortfolioManager.Website.TPM"> 
     <endpoint address="" behaviorConfiguration="VZW.TrainingPortfolioManager.Website.TPMAspNetAjaxBehavior" 
      binding="webHttpBinding" contract="VZW.TrainingPortfolioManager.Website.TPM" /> 
     </service> 
    </services> 
    <bindings> 
     <basicHttpBinding> 
     <binding> 
      <security mode="TransportCredentialOnly"> 
      <transport clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     </basicHttpBinding>  
    </bindings> 
    </system.serviceModel> 

然而,當我在瀏覽器中加載Web服務,我得到錯誤信息:

Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service. 

還有什麼我需要改變或配置爲得到這個工作?

回答

0

想通了。 endpoint上的binding屬性必須與<bindings>集合中的節點相匹配。以下將起作用:

<bindings> 
    <webHttpBinding> 
    <binding> 
     <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Windows" /> 
     </security> 
    </binding> 
    </webHttpBinding>  
</bindings>