2014-02-24 42 views
7

我使用客戶端憑證創建WCF應用程序。它在內部工作正常,而我從另一個項目中引用並調用此服務意味着我收到了錯誤消息。未提供用戶名。在ClientCredentials中指定用戶名

The username is not provided. Specify username in ClientCredentials. 

請幫我解決這個問題。

<bindings> 
    <wsHttpBinding> 
<binding name="WSHttpBinding_IWcfService" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
       bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
       messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
       allowCookies="false"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <reliableSession ordered="true" inactivityTimeout="00:10:00" 
        enabled="false" /> 
       <security mode="TransportWithMessageCredential"> 
        <transport clientCredentialType="None" proxyCredentialType="None" 
         realm="" /> 
        <message clientCredentialType="UserName" negotiateServiceCredential="true" 
         algorithmSuite="Default" /> 
       </security> 
      </binding> 
    </wsHttpBinding> 
</bindings> 
<client> 
<endpoint address="https://wcfauthtest.sbs.in:448/WcfService.svc/WcfService.svc" 
       binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IWcfService" 
       contract="AuthTest.IWcfService" name="WSHttpBinding_IWcfService"> 
       <identity> 
        <dns value="localhost" /> 
       </identity> 
</endpoint> 
</client> 

任何幫助?

+0

我的回答有助於解決您的問題嗎?如果問題得到解決,請不要忘記將問題標記爲答案。 – Seany84

+0

嗨,那裏有關於這個問題的任何更新?我的回答是否幫助你? – Seany84

回答

4

你有沒有指定的對事物的客戶端/消費終端的憑據:

WcfService.UserName.UserName = "user"; 
WcfService.UserName.Password = "pass"; 

你應該做的WCF服務的任何呼叫在您的代碼之前提供這些憑證。

+0

上午WCF請指定我在哪裏添加此 – user3085540

+0

是我在消費者端添加了 – user3085540

+0

這是否解決了您的問題?在對代碼中的WCF服務進行任何調用之前,您應該提供這些憑據。 – Seany84

相關問題