2011-02-07 21 views
0

我有一個WCF問題。一直呆在這裏好幾天。因特網上的WCF錯誤只有

  • 我有我的WCF服務和客戶端在Intranet上完美工作。
  • 我在通過Internet公開的IIS服務器上部署了相同的服務/客戶端。這項服務,我能夠完全從我的工作站訪問,使用互聯網網站(.com地址)
  • 但是,當使用未連接到我們網絡的計算機訪問相同的.com網站時,它給我帶來了可怕的「 HTTP請求未經授權,客戶端認證方案爲「協商」,從服務器收到的認證頭是「協商,NTLM」,當訪問服務時

其他信息:客戶端認證我。當客戶端訪問WCF服務時,出現錯誤。

客戶的Web.Config:

<system.serviceModel> 
    <bindings> 
    <basicHttpBinding> 
    <binding name="BasicHttpEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" 
    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="true" 
    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
    useDefaultWebProxy="true"> 
    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
     maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
    <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Windows" proxyCredentialType="None" 
     realm="" /> 
     <message clientCredentialType="UserName" algorithmSuite="Default" /> 
    </security> 
    </binding> 
    </basicHttpBinding> 
    </bindings> 
    <client> 
    <endpoint address="http://exposedoutside.com:80/site/myservice.svc" 
    binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpoint" 
    contract="WFLServiceReference.IWorkflow" name="BasicHttpEndpoint" /> 
    </client> 
    <behaviors> 
    <endpointBehaviors> 
     <behavior name=""> 
     <dataContractSerializer maxItemsInObjectGraph="2147483646"/> 
     <clientCredentials> 
      <windows allowedImpersonationLevel="Impersonation"/> 
     </clientCredentials> 
     </behavior> 
    </endpointBehaviors> 
    </behaviors> 
</system.serviceModel> 

我並不真的需要指定的端口。此外,我在代碼隱藏

Dim wcfService = New WCFServiceProxy.myserviceClient() 
wcfService.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation 

我錯過了什麼嗎?

預先感謝您。

回答

0

確保將IIS設置爲允許在該Web應用程序上進行匿名身份驗證。你想自己處理認證,所以你需要告訴IIS允許每個人。這是一件好事,只要你確信你已經完成了你的認證。

,因爲它是使用Windows域憑據登錄它從本地機器的工作原理。最簡單的檢查是在Web瀏覽器中打開了WCF終點(即類型http://exposedoutside.com:80/site/myservice.svc到地址欄)

+0

謝謝您的回覆。但是,我想在客戶端應用程序上使用Windows身份驗證(我也嘗試啓用匿名,發生同樣的事情)。我也嘗試打開端點,它可以從未連接到網絡的計算機訪問。 – John 2011-02-07 02:47:55

+0

對不起,您的文章有誤。啓用匿名時,您需要關閉所有其他選項。您可能需要轉而集成並使用摘要。如果連接的計算機位於相同的域中,則集成通常是。 – 2011-02-07 03:12:51

0

你無法通過Internet使用clientCredentialType =「Windows」(協商)。它只適用於客戶端和服務器位於相同域或受信任域的情況。如果您確實希望通過Internet對Windows帳戶進行身份驗證,則必須將clientCredentialType設置爲Basic的端點公開。它將使用基本身份驗證,因此客戶端必須明確提供用戶名和密碼。請注意,公開此類沒有傳輸安全性(HTTPS)的端點是不可接受的,因爲您將以純文本形式通過Internet向您的網絡發送憑證。

0

顯然,我只需要通過憑據。我一直在迴避的態度,但現在看來,它的真正要走的路:

clientProxyHere.ClientCredentials.HttpDigest.ClientCredential = New System.Net.NetworkCredential("user", "password")