WCF 客户端 - 如何处理或忽略 MustUnderstand 标头元素? [英] WCF Client - How to process or ignore a MustUnderstand header element?

查看:29
本文介绍了WCF 客户端 - 如何处理或忽略 MustUnderstand 标头元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个 WCF 客户端,它使用非 .Net 网络服务,使用 WS-Security.服务的响应包含一个安全标头,其中 mustUnderstand 设置为 true.

I'm writing a WCF Client that consumes a non-.Net web service, using WS-Security. The service's response contains a Security header with mustUnderstand set to true.

使用 ServiceModelListener,我确实看到了从服务返回的实际数据.但是,WCF 客户端失败,因为它没有处理安全标头.

Using a ServiceModelListener, I do see actual data coming back from the service. The WCF client fails, however, because it is not processing the Security header.

<env:Header>
<wsse:Security env:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Timestamp wsu:Id="timestamp">
<wsu:Created>2012-03-28T13:43:54.474Z</wsu:Created>
<wsu:Expires>2012-03-28T13:48:54.474Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</env:Header>

WCF 客户端错误消息:

WCF Client Error Message:

来自命名空间 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' 未被此消息的接收者理解,导致消息不被处理.此错误通常表示此消息的发送方启用了接收方无法处理的通信协议.请确保客户端绑定的配置与服务的绑定一致.

The header 'Security' from the namespace 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' was not understood by the recipient of this message, causing the message to not be processed. This error typically indicates that the sender of this message has enabled a communication protocol that the receiver cannot process. Please ensure that the configuration of the client's binding is consistent with the service's binding.

我的 WCF 客户端不需要任何时间戳信息.是否有一种简单的方法可以在处理例程中存根?我已经尝试扩展 Response 类 &添加 [MessageHeader] 属性.

My WCF client doesn't need any of the timestamp info. Is there an easy way to stub in a processing routine? I've already tried extending the Response class & adding a [MessageHeader] property.

以另一种方式提问:如何实现一个 WCF 客户端,该客户端接受标记为必须理解的自定义标头元素?

Asked another way: How do I implement a WCF client that accepts custom header elements that are marked Must Understand?

推荐答案

WS-Security 有不同的标准.在客户端更改绑定可能是有意义的,因为 basicHttpBinding 和 wsHttpBindings 使用不同的安全标准.

There is different standards of WS-Security. Might be it make sense to change the binding at client side, since basicHttpBinding and wsHttpBindings are working with different security standards.

这篇关于WCF 客户端 - 如何处理或忽略 MustUnderstand 标头元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆