简体   繁体   中英

Serializing Response received from WCF service with DataContractSerializer

We are trying to capture the request and response to/from WCF services in our log.

When serializing the response received from WCF service using DataContractSerializer, the serialized response is not containing the properties of the message contract, it just contains namespace information.

But we are able to capture the properties of message contract when we use XML Serializer instead of DataContractSerializer. These requires changing our base message contract to have a public properties instead of internal which we dont want to.

Is there anyway to capture the properties of message using DataContractSerializer?

You can use a Message Inspector for logging the actual request and response in the client as well as the service. More details on how to implement one can be found in https://msdn.microsoft.com/en-us/library/aa717047%28v=vs.110%29.aspx , http://cgeers.com/2011/05/10/wcf-message-logging/ and http://blogs.msdn.com/b/carlosfigueira/archive/2011/04/19/wcf-extensibility-message-inspectors.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM