简体   繁体   English

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

[英]Retrieving the MessageId automatically set by WCF when using WSHttpBinding

I use WCF to consume a web service that respect the WS form (I then use WSHttpBinding binding). 我使用WCF来使用尊重WS表单的Web服务(然后使用WSHttpBinding绑定)。 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. 这种形式涉及在soap请求的标头中设置的MessageIDRelatesTo字段的响应标头中存在的相同ID。 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. 我想记录与该MessageId一起发出的请求,但是找不到一种方法来检索WCF设置的messageId,也可以手动设置。 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. 通过在字段上设置正确的属性,我设法从响应中获取了它,但是在请求中这样做让我进行了设置,但似乎WCF会覆盖它,并且在进行调用之后,我不允许我访问新的value事件。

Any idea ? 任何想法 ?

I didn't find a way to retrieve the automatically set message ID either, but you can set it manually easily: 我也没有找到检索自动设置的消息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
    }

Hope that helps 希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用wsHttpBinding时如何在WCF中解雇 - How to fire-and-forget in WCF when using wsHttpBinding 使用wsHttpBinding的WCF服务配置 - Configuration of WCF Service using wsHttpBinding 使用wshttpbinding的WCF用户名和密码验证不起作用 - WCF UserName & Password validation using wshttpbinding notworking 使用wshttpbinding通过Internet消耗WCF服务吗? - Consume WCF service over the internet using wshttpbinding? 使用Web参考将wCF服务与wsHttpBinding一起使用 - Consume WCF service with wsHttpBinding using web reference WCF性能使用wsHttpBinding传输对象列表 - WCF performance transferring List of objects using wsHttpBinding 使用浏览器访问Web服务将WCF绑定设置为wsHttpBinding,并将其作为basicHttpBinding - WCF Binding set to wsHttpBinding using browser to access Web Service has it as basicHttpBinding 通过反射WSHttpBinding在WCF中设置ReaderQuotas.MaxStringContentLength - Set ReaderQuotas.MaxStringContentLength, in WCF via reflection WSHttpBinding 使用wshttpbinding和用户名身份验证保护服务时,WCF服务显示异常 - WCF service show exception when securing service with wshttpbinding and username authentication 您可以使用SOAP和WSHttpBinding对WCF服务进行jQuery调用吗? - Can you make a jQuery call to WCF service using SOAP and WSHttpBinding?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM