1

I have a bunch of great, working code that access various REST (and sometimes SOAP) apis. It is all WCF in .NET 4.0 based.

But sometimes the system I access returns bad xml (ahhhh, developers who build xml with strings... bad people!).

So the XML is bad,,, and WCF throws (as it should)... system.invalidoperationexception ... error in xml document ... [The string FOO is not a valid Boolean value][or some other parsing error]...

I need to log the full raw xml of the HTTP POST/GET response (the response that failed to deserialize). For some reason, I can't seem to figure out where in WCF land to find this.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Jonesome Reinstate Monica
  • 6,618
  • 11
  • 65
  • 112
  • possible duplicate of [Intercept messages in a WCF Client](http://stackoverflow.com/questions/1217374/intercept-messages-in-a-wcf-client) – Jesse C. Slicer Jan 29 '13 at 03:44
  • Not really a duplicate of that, since for this scenario a message inspector (listed in the answer to that post) won't help. – carlosfigueira Jan 29 '13 at 06:08

2 Answers2

1

If you need to access the raw data for the request, the place where you'll want to go is a custom message encoder. What you can do is to create your own encoder (possibly wrapping the existing one), and at that point you get the raw bytes coming from the transport layer. You can find more information about custom encoders at http://blogs.msdn.com/b/carlosfigueira/archive/2011/11/09/wcf-extensibility-message-encoders.aspx.

carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
0

Enable tracing and see where do you have a problem. There is a nice app AppFabric, where you can easily change you tacing settings and see the messages with the exceptions. See http://msdn.microsoft.com/en-us/library/ms751526.aspx

Alex
  • 8,827
  • 3
  • 42
  • 58