1

Say I have the standard Service.svc deployed like this:

public class Service1 : IService1
{
    public string GetData(int value)
    {
        return string.Format("You entered: {0}", value);
    }

    public CompositeType GetDataUsingDataContract(CompositeType composite)
    {
        if (composite == null)
        {
            throw new ArgumentNullException("composite");
        }
        if (composite.BoolValue)
        {
            composite.StringValue += "Suffix";
        }
        return composite;
    }
}

and a client like this:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        ServiceReference1.Service1Client s1 = new ServiceReference1.Service1Client();
         string str = s1.GetData(1);

    }
}

The web service returns the following text to the str variable (as expected): "You entered: 1". How do I see the SOAP/XML that was generated?

I realise I could use Fiddler, however I want to see it in .NET i.e. returned to the str variable..

w0051977
  • 15,099
  • 32
  • 152
  • 329
  • you could hit the endpoint with function calls and parameters with an HTTP client instead of the service proxy I would imagine... what are you trying to accomplish with this? – Kritner Dec 08 '16 at 14:22

1 Answers1

1

One of the main benefits WCF has to offer is abstracting you from any serialization/transport issues. Since your service contract returns CompositeType you get an instance of it automatically reconstructed from the underlying XML message on the client side.

However, if you want to get a raw XML you can still do that by performing direct call depending on what transport is supported by your WCF server. if it's basicHttpBinding/wsHttpBinding you can perform HTTP request and read a response which will be pure XML. Of course, all the dirty work like authentication and security is on you.

If you need this just for debugging/studying purposes you can enable message logging or use standard WcfTestClient.exe utility.

UserControl
  • 14,766
  • 20
  • 100
  • 187