8

I have a WCF Client (console app) that calls a WCF web service and I'm trying to get the raw XML response from within my Console Application.

Does anyone have an idea or code snippet on how to do this?

Kevin Jensen
  • 1,418
  • 3
  • 18
  • 25

2 Answers2

4

You could use a client Message Inspector

Check out this link

In your BeforeSendRequest you can simply call ToString() on the message.

Dog Ears
  • 9,637
  • 5
  • 37
  • 54
-1

I was able to get the raw xml using this method:

string _serial = SerializeObj(retVal);

public string SerializeObj<T>(T obj)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(obj.GetType());

            using (StringWriter txtWriter= new StringWriter())
            {
                xmlSerializer.Serialize(txtWriter, obj);
                return txtWriter.ToString();
            }
        }
Tyrone Moodley
  • 3,442
  • 1
  • 15
  • 16
  • This returns the value after it has already been processed by WCF. It does not return the *raw* xml – NotMe Jun 30 '21 at 19:38