WCF gurus,
you probably already know the answer I cannot find …
let’s say I have some web service (WCF) and a client application (based on curl library). Sometimes on the server site I got the strange error:
The OperationFormatter could not deserialize any information from the Message because the Message is empty (IsEmpty = true).
System.Runtime.Serialization.SerializationException: The OperationFormatter could not deserialize any information from the Message because the Message is empty (IsEmpty = true).
Source: System.ServiceModel
Stack trace:
at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRequest(Message message, Object[] parameters)
Rethrown as:
System.ServiceModel.CommunicationException: Error in deserializing body of request message for operation ‘…’. The OperationFormatter could not deserialize any information from the Message because the Message is empty (IsEmpty = true).
Source: System.ServiceModel
Stack trace:
at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.CompositeDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
…
On the client site I see (in the log) that a client sends a request and the request is not empty (has some body) but I would like to verify that WCF receives this request from the wire.
How can I do that?
Ideally I would log an incoming request (raw bytes) in the error handler like System.ServiceModel.Dispatcher.IErrorHandler, otherwise collect the data somewhere and then log them while the error happens (some kind of low-level http traffic proxy on the server side?).
Another solution could be install Wireshark on the server site but I prefer avoid it because it happens on customer site and I do not have any access to her machine.
Thanks!
I think, I found good a little bit complicated solution. If you need to do something like what I have asked in the question, you need to implement
MessageEncoderand install it viaMessageEncodingBindingElement. OverrideReadMessage(...)methods inMessageEncoder, there you will have access to the buffer that contains raw incoming body.