【发布时间】:2011-05-13 22:23:57
【问题描述】:
我有一个客户用户名/密码验证器。将它放在 web.config 的端点 bindingConfiguration 属性中是否足够,或者我是否需要在 Service 方法中显式调用它。我注意到当我不将其称为服务操作时,它不会被调用。我做错了吗?
这就是我定义绑定部分的方式:
<bindings>
<wsHttpBinding>
<binding name="CustomAuthentication">
<security mode="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
这就是我定义服务节点的方式:
<service behaviorConfiguration="CustomValidator" name="Test.TestService">
我的端点属性有它的 BindingConfiguration = "CustomAuthentication"
这就是我在 ServiceBehaviors 中定义行为的方式:
<behavior name="CustomValidator">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="Test.CustomUserNameValidator, FuzionSync"/>
<serviceCertificate findValue="MyWebSite" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
</serviceCredentials>
<serviceMetadata httpGetEnabled="True"/>
</behavior>
当我运行 wcf 测试客户端来调用服务调用时,它甚至没有调用 Validate 方法。我让它调用的唯一方法是,如果我把它放在一个要显式调用的操作中。
【问题讨论】:
-
如果我是对的,在连接到 wcf 服务之前,您需要使用这些作为凭据。
-
@BreakHead,我对你的回复感到困惑?