views:

23

answers:

1

Assume I have code like this:

var svc = new Namespace.SvcClient();
var request = new Namespace.SvcRequest();
request.SomeProperty = "Value1";
request.SomeProperty = 4.0d;
var response = svc.Request(request);
SetText(response.Result.ToString());
svc.Close();

What I want to have is the actual XML that got sent out as the result of svc.Request(request); and the actual XML response from the server, but I want these from WITHIN my application code. I don't want to log it to a file or anything like that. I want to display the xml to the user.

+2  A: 

See Configuring Message Logging. You can turn on message tracing and get the exact XML.

John Saunders
How do I get this into a textbox cleanly? Do I have to do Trace -> File -> System.IO.File.Read -> MyTextbox.Text, that doesn't seem very clean, but maybe there is no better way?
Nate Bross
Sorry, I didn't get the fact that you want to display it to the user. What if the format isn't XML? Remember that WCF can do a lot more than just SOAP.
John Saunders
I realize that, in my case it will be SOAP, but I'm interested in getting the RAW message data (whatever it is) and display it to the user of the application.
Nate Bross
See [Message Inspectors](http://msdn.microsoft.com/en-us/library/aa717047.aspx).
John Saunders