开发者

How to get raw XML in WCF Client from Web Service call

开发者 https://www.devze.com 2023-01-14 23:13 出处:网络
I have a WCF Client (console app) 开发者_StackOverflow社区that calls a WCF web service and I\'m trying to get the raw XML response from within my Console Application.

I have a WCF Client (console app) 开发者_StackOverflow社区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?


You could use a client Message Inspector

Check out this link

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


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();
            }
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消