2012-03-27 132 views
1

你好我特林使用這篇文章使我的WCF服務的身份驗證不使用SSL配置綁定擴展「system.serviceModel /綁定/ clearUsernameBinding」找不到

http://webservices20.blogspot.in/2008/11/introducing-wcf-clearusernamebinding.html

,但我歌廳這個錯誤當我嘗試編譯:

<system.serviceModel> 
<extensions> 
    <bindingExtensions> 
    <add name="clearUsernameBinding" type="ClearUsernameCollectionElement, ClearUsernameBinding" /> 
    </bindingExtensions> 
</extensions> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="ServiceBehavior"> 
     <serviceCredentials> 
     <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyValidator,App_Code"/> 
     </serviceCredentials> 

     <!--To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment--> 
     <serviceMetadata 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> 
    <behavior name="SampleServiceBehaviour"> 
     <serviceMetadata httpsGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="false"/> 
     <serviceCredentials> 
     <userNameAuthentication userNamePasswordValidationMode="Custom" 
     customUserNamePasswordValidatorType="MyUserNameValidator, App_Code" /> 
     </serviceCredentials> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<services> 
    <service name="Service" behaviorConfiguration="SampleServiceBehaviour"> 
    <endpoint address="~/QuadraService/Service.svc" binding="wsHttpBinding" contract="IService" bindingConfiguration="Binding1"/> 
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/> 
    <endpoint binding="clearUsernameBinding" bindingConfiguration="myClearUsernameBinding" contract="IService" /> 
    </service> 
</services> 
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> 
<bindings> 

    <clearUsernameBinding> 
    <binding name="myClearUsernameBinding" 
messageVersion="Soap12"> 
    </binding> 
    </clearUsernameBinding> 

    <wsHttpBinding> 

    <binding name="Binding1"> 
     <!-- UsernameToken over Transport Security --> 
     <security mode="TransportWithMessageCredential" > 
     <message clientCredentialType="UserName"/> 
     </security> 
    </binding> 
    </wsHttpBinding> 



</bindings> 

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 
Parser Error Message: Configuration binding extension 'system.serviceModel/bindings/clearUsernameBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly. 

請幫忙

+0

錯誤其實很清楚。檢查你的web.config/app.config或配置代碼,以確保WCF綁定擴展配置正確。如果你將配置置入你的問題,這將有所幫助。 – 2012-03-27 17:09:31

+0

@SixtoSaez感謝您的回覆,我在問題中添加了配置代碼。現在請檢查您是否發現任何錯誤。 – Sunny 2012-03-28 04:30:00

+0

我檢查了配置文件,問題解決了,但現在我又收到另一個錯誤: - 「驗證郵件安全性時發生錯誤。」當試圖在客戶端使用服務 – Sunny 2012-03-28 05:31:50

回答

0

好像你收到「驗證消息安全性時發生錯誤」異常,因爲你沒有手動修改客戶端上的配置文件。

筆者狀態的評論如下:

對於桌面應用程序,客戶端需要手動配置 clearUsernameBinding作爲示例控制檯應用程序來完成。 原因是clearUsernameBinding DLL不是.Net 3.5 的一部分,需要在客戶端部署。