I have implemented a message inspector in WCF by implementing IDispatchMessageInspector
.
Putting a break point on this method...
public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
{
// Impementation
}
... I can look at the request
object to see what is inside.
Clearly I dont understand WCF enough because whatever endpoint binding I use (basichttp, nettcp and netpipe) the message inside is always represented in SOAP format e.g.
<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">
<s:Header>
-- headers --
</s:Header>
<s:Body>
-- body --
</s:Body>
</s:Envelope>
Is this because doing a .ToString() on the request object just represents the message in SOAP format?
I imagined that using another protocol e.g. netTcp would result in a different message payload.
Also lets say I wanted to represent my data in JSON format how would I go about doing this? Or would I end up with JSON formatted data structures inside a SOAP envelope?