如何拦截 SOAP 消息
作为我涉足 WCF 的一部分,我正在研究消息契约并了解它们如何影响 SOAP 消息的内容。
如果您能够拦截该消息并查看其结构,那就太酷了。请问我该怎么做呢...
(到目前为止,我已经研究过 Wireshark(太“低级”)并考虑过 Microsoft SOAP 工具包,但该工具包早在 2005 年就被微软淘汰了)
As part of my venture into WCF I'm looking at message contracts and seeing how they affect the content of the SOAP message.
What would be really cool is if you could intercept the message and see how it is structured. How would I go about doing this please...
(So far I've looked at Wireshark (too 'low-level') and thought about Microsoft SOAP toolkit but this was retired by microsoft back in 2005)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当您安装 .NET 3.5 或更高版本时,您应该拥有 WCF 测试客户端 在你机器上的某个地方(隐藏在 C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ 等目录深处)。
这个工具允许您连接到您的 WCF 服务,您可以调用它的方法 - 并且您可以查看 XML 请求和响应的所有优点 :-)
另一种选择是使用免费版本的 SoapUI 这是设计的测试 SOAP 服务并以 XML 形式显示请求和响应
SoapUI 是一个很棒的工具 - 但它不是特定于 WCF 的,它只是一个“通用”SOAP/WSDL 工具,适用于任何 SOAP 服务。
如果您不是在寻找“按需”捕获请求和响应,但如果您对跟踪所有请求和响应更感兴趣,则应该研究 WCF 跟踪功能 并根据需要进行设置。您可以将所有流量捕获到磁盘上的
*.svclog
文件中,其中有 WCF 服务跟踪查看器(WCF 也免费)用于检查这些跟踪文件。When you installed .NET 3.5 or up, you should have the WCF Test Client on your machine somewhere (hidden deep inside a directory like
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\
or something like that).This tool allows you to connect to your WCF service, and you can call methods on it - and you can look at the XML request and response in all its beauty :-)
The other option would be to use something like the free version of SoapUI which is designed to test SOAP services and show request and response in XML
SoapUI is a great tool - but it's not WCF specific, it's just a "generic" SOAP/WSDL tool which works great against any SOAP service.
If you're not looking for "on-demand" capturing of requests and responses, but if you're more interested in having a trace of all requests and responses, you should investigate the WCF tracing features and setup them up as needed. You can capture all traffic into a
*.svclog
file on disk, and there's the WCF Service Trace Viewer (also free with WCF) to inspect those trace files.我通常使用 Fiddler 来检查通过 http 发送的肥皂消息。
I usually use Fiddler to inspect soap messages sent over http.
如果你想写一条日志记录,可以尝试使用TraceExtension类,下面是一个例子,
在此链接中,您将找到有关如何实现它的详细信息,我使用它并且效果非常好
http://www.systemdeveloper.info/2013/11/trace-soap-requestresponse-xml-with.html
If you want to write a log record is try using TraceExtension class, below an example,
in this link you will find details about how to implement it, I use it and it worked very well
http://www.systemdeveloper.info/2013/11/trace-soap-requestresponse-xml-with.html