使用 WSHttpBinding 时检索 WCF 自动设置的 MessageId

发布于 2024-10-01 13:02:33 字数 291 浏览 0 评论 0原文

我使用 WCF 来使用遵循 WS 表单的 Web 服务(然后使用 WSHttpBinding 绑定)。此表单涉及在肥皂请求标头中设置的 MessageID 以及在响应标头的 RelatesTo 字段中存在的相同 ID。我想记录我发出的请求以及此 MessageId,但找不到检索 WCF 设置的 messageId 的方法,我也可以手动设置它。我设法通过在字段上设置正确的属性来从响应中获取它,但在请求上这样做让我可以设置它,但似乎 WCF 会覆盖它并且不允许我在调用后访问新值事件。

有什么想法吗?

I use WCF to consume a web service that respect the WS form (I then use WSHttpBinding binding). This form involves a MessageID to be set in the header of the soap request and the same id being present in the reponse header in the RelatesTo field. I'd like to log the request I made along with this MessageId but can't find a way to retrieve the messageId set by WCF either can I set it manually. I managed to get it from the response by setting the right attribute on the field but doing so on the request let me set it but is seems WCF overrides it and don't let me accessing the new value event after the call has been made.

Any idea ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蹲墙角沉默 2024-10-08 13:02:33

我也没有找到检索自动设置的消息 ID 的方法,但您可以轻松手动设置它:

using (new System.ServiceModel.OperationContextScope((System.ServiceModel.IContextChannel)base.Channel))
    {
        m_lastMessageId = new System.Xml.UniqueId();
        System.ServiceModel.OperationContext.Current.OutgoingMessageHeaders.MessageId = m_lastMessageId;
        // call here the request
    }

希望有帮助

I didn't find a way to retrieve the automatically set message ID either, but you can set it manually easily:

using (new System.ServiceModel.OperationContextScope((System.ServiceModel.IContextChannel)base.Channel))
    {
        m_lastMessageId = new System.Xml.UniqueId();
        System.ServiceModel.OperationContext.Current.OutgoingMessageHeaders.MessageId = m_lastMessageId;
        // call here the request
    }

Hope that helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文