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

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

问题描述

我正在使用WS-Security编写一个使用非.Net Web服务的WCF客户端.服务的响应包含一个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客户端失败,因为它没有处理Security标头.

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客户端?

推荐答案

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天全站免登陆