2008-12-27 80 views
25

我已经编写了一个非常简单的WCF服务来发送和接收消息。我已通过VS 2008默认Web服务器主机测试了该应用程序,并且一切正常。但是,当我将WCF服务部署到另一台计算机的IIS时,我收到以下错误:WCF:由于验证失败,无法满足安全令牌请求

“由于验证失败,无法满足安全令牌请求。”

如何设置使用个性化的用户名和密码在配置文件中的身份验证类型? 如果这是不可能的,请告诉我如何设置其Windows凭据,因为我使用的2台计算机不共享相同的用户。

回答

32

您需要关闭绑定的安全性。否则,我相信,默认情况下,wsHttpBinding将尝试协商安全上下文令牌(SCT)。

所以,修改端点定义为指向的结合配置部分。这里有一个例子:

<endpoint address="" 
      binding="wsHttpBinding" 
      contract="HelloWorldService.IService1" 
      bindingConfiguration="TheBindingConfig"> 

然后在web.config中的<system.serviceModel>部分<services>节之后添加类似以下的绑定配置。

将安全设置为“无”是关键。

希望这有助于!


上面帮我 - 但究竟是不是立即明显的是如何添加到服务末(其明确的,一旦你已经做了什么需要,但直到你已经这样做了)。其原因并不完全明显是因为缺省情况下没有绑定部分,而客户端中可能存在绑定部分。

所以,只需要非常清楚 - 在服务端,添加绑定部分(如上所述),然后添加到适当的端点添加bindingConfiguration =“TheBindingConfig”属性。很明显,一旦你已经做了一次......

+4

我认为这是一个不好的答案automiticaly去关闭安全 – TruthOf42 2013-11-01 20:32:51

12

一定要客户端和服务器上设置此bindingConfiguration(指定安全模式“无”),否则你会得到这样的信息 - 这是一个相当红鲱鱼至于调试问题。

The message could not be processed. This is most likely because the action ' http://tempuri.org/IInterfaceName/OperationName ' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.

20

您实际上并不需要关闭安全性,在某些情况下您不应该关闭安全性。在一个bindingConfiguration,您可以指定消息级安全性进行如下的不建立安全上下文:

<security mode="Message"> 
    <transport clientCredentialType="Windows" proxyCredentialType="None" 
         realm="" /> 
    <message clientCredentialType="Windows" negotiateServiceCredential="true" 
     algorithmSuite="Default" establishSecurityContext="false" /> 
</security> 

注意establishSecurityContext属性。客户端和服务都应该具有安全配置,其中establishSecurityContext设置为相同的值。 true值也可以正常工作,但在服务器负载均衡的环境中建议使用false。

+0

+1这是一个漂亮的第一篇文章先生! – 2010-11-16 16:09:19

0

如果你在调试模式,则默认设置调试属性为

<serviceDebug includeExceptionDetailInFaults="true"/> 

,而你去调试它抛出异常它设置为假..所以。

希望它有帮助。

相关问题