我有 SOAP 网络服务的 WSDL,我正在通过我的 MVC 应用程序使用它。
通过将 WSDL 作为 Web 服务添加到我的 Visual Studio 解决方案,它会自动为我创建一个代理类,并为我处理所有序列化/不稳定,这在一段时间内真的很棒。我一直在使用这个代理类来调用/发送我的 SOAP 请求到 Web 服务(使用纯 c# 代码,不涉及 XML),我收到了我的响应消息,一切都运行良好。
但是,现在我需要找到发送到 Web 服务的 SOAP 消息的确切 xml 表示形式。我怎样才能得到/找到/制作这个?
最佳答案
你可以这样做
var serxml = new System.Xml.Serialization.XmlSerializer(request.GetType());
var ms = new MemoryStream();
serxml.Serialize(ms, request);
string xml = Encoding.UTF8.GetString(ms.ToArray());
其中 xml 是您的原始 SOAP
关于c# - 如何获取 SOAP 请求消息的 xml 表示形式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46781656/