I'm generating a WCF service using the message contract model.
I have created a generic request message contract like so:
[MessageContract]
public Request<T>
{
[MessageBodyMember]
public T Details { get; set; }
}
I'm used to using [DataContract(Name="Contract{0}")]
to produce readable names for generic data contracts, but this approach does not seem to work for me using message contracts.
Is there a way to achieve the same behaviour using the message contract model?
It seems like a lot of work for what you want to accomplish, but I believe you can create a MessageInspector which will allow you to interact directly with the XML.
Client message inspectors implement the IClientMessageInspector
interface and service message inspectors implement the IDispatchMessageInspector
interface.
http://msdn.microsoft.com/en-us/library/aa717047.aspx
Any service (dispatcher) message inspector must implement the two IDispatchMessageInspector
methods AfterReceiveRequest
and BeforeSendReply
.
The link goes into much more detail, but once you have these implemented, you should be able to add the inspector to your web.config and you should be all set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With