[英]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请求的标头中设置的MessageID
和RelatesTo
字段的响应标头中存在的相同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.