Pergunta

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 ?

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top