2016-08-17 29 views
0

寫了一個以BasicHttpBinding開頭的Web服務,以便簡單開發服務而不必擔心安全性。在將它移動到Web服務器時,我將綁定切換到WsHttpBinding以及Web服務器上的另一個Web服務一樣的基本身份驗證。但是,當我瀏覽到Web服務來驗證它正在運行時,它表示配置的綁定仍然是BasicHttpBinding。已驗證的IIS指向正確的位置。WCF綁定設置爲wsHttpBinding使用瀏覽器訪問Web服務將其作爲basicHttpBinding

主機上配置的身份驗證方案('Basic')不允許在綁定'BasicHttpBinding'('Anonymous')上配置的身份驗證方案。請確保SecurityMode設置爲Transport或TransportCredentialOnly。另外,可以通過在應用程序配置文件的>元素處通過IIS管理>工具,通過ServiceHost.Authentication.AuthenticationSchemes>屬性更改此應用程序的>認證方案,通過更新綁定上的ClientCredentialType屬性來解決此問題或者通過調整HttpTransportBindingElement上的AuthenticationScheme屬性。

的Web.config

<configuration> 
    <appSettings> 
    </appSettings> 
    <system.web> 
     <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
     <bindings> 
     <wsHttpBinding> 
      <binding name="MyBinder"> 
      <security mode="Transport"> 
       <transport clientCredentialType="Basic"></transport> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <services> 
     <service name="MyService"> 
     <endpoint address="" 
       binding="wsHttpBinding" 
       bindingConfiguration="MyBinder" 
       name="MyEndpoint" 
       contract="MyService.IMyInterface"></endpoint> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name=""> 
       <serviceMetadata httpsGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="false" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
</configuration> 

回答

0

解決它。刪除底部的ServiceHostingEnvironment標記,並注意到它使用的是WsHttpBinding,然後必須讓我的服務名稱與服務的namespace.class匹配。一旦這個設置一切正常。

相關問題