2011-02-07 38 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")