![](/img/trans.png)
[英]Why is my WCF wshttpbinding client doesn't work at another computer?
[英]Why is the WCF wsHttpBinding Timestamp optional?
我们有一个使用wsHttpBinding的WCF服务。 我生成的示例请求包括一个时间戳,该时间戳已由WCF针对每个请求进行了验证:
<u:Timestamp u:Id="_0">
<u:Created>2013-11-02T16:58:24.575Z</u:Created>
<u:Expires>2013-11-02T17:03:24.575Z</u:Expires>
</u:Timestamp>
最近,我们对该服务进行了笔测试,测试人员注意到可以省略timestamp元素,并且无需它就可以接受请求。
我正在查看报告,并为此添加解释。 不幸的是,我进行了很好的搜索,但是找不到任何可以解释甚至提及它的资源。
所以我的问题是:
这是服务绑定配置:
<wsHttpBinding>
<binding name="usernameHttps" maxReceivedMessageSize="2147483647">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
这是客户端绑定配置:
<wsHttpBinding>
<binding name="WSHttpBinding_IService" maxReceivedMessageSize="2147483647">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
- 为什么这是可选的?
时间戳是可选的,因为必须对它采取行动,它来自MSDN http://msdn.microsoft.com/zh-cn/library/ms977327.aspx
“通过了解创建和到期时间,接收者可以决定数据是否足够新以供自己使用,或者数据是否过时以至于消息应被丢弃。”
- 如果我被问到,是否可以强制设置时间戳记?
是的,如上所述,这是您的服务逻辑所需要的,最简单的方法是在WCF处理管道中添加一个拦截器,该拦截器将检查此标头,如果找不到,则会引发错误http://msdn.microsoft.com /zh-CN/magazine/cc163302.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.