C# SOAP Web 服务客户端 - 显示如何记录所有原始 SOAP 输入和输出的示例?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/566855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 08:27:42  来源:igfitidea点击:

C# SOAP Web Services client - example that shows how to log all raw SOAP intput and output?

c#web-servicesloggingsoap

提问by Keith Palmer Jr.

I'm looking for a C# example showing how to access a remote SOAP Web Service, and logging (to a file, or even just to a string I can do whatever with) all complete raw SOAP requests and complete raw SOAP responses.

我正在寻找一个 C# 示例,展示如何访问远程 SOAP Web 服务,并记录(记录到文件,甚至只是记录到我可以做任何事情的字符串)所有完整的原始 SOAP 请求和完整的原始 SOAP 响应。

I found some other posts on StackOverflow with similar topics, but they seem to reference a web.config file, which my desktopapplication does not have. I assume this is because they are using C# in the form of a web application querying a remote SOAP web service. Mine is a desktop application.

我在 StackOverflow 上发现了一些其他类似主题的帖子,但它们似乎引用了我的桌面应用程序没有的 web.config 文件。我认为这是因为他们以 Web 应用程序的形式使用 C# 来查询远程 SOAP Web 服务。我的是桌面应用程序。

Any takers?

有接班人吗?

采纳答案by nzpcmad

You could use SOAP extensionsto get the SOAP content as a string and then log it wherever.

您可以使用SOAP 扩展以字符串形式获取 SOAP 内容,然后将其记录在任何地方。

回答by Tom A

See this answerfor info on WCF logging. You can log to a file, and there is a special viewer to make reading the logs easy.

有关WCF 日志记录的信息,请参阅此答案。您可以登录到文件,并且有一个特殊的查看器可以让您轻松阅读日志。

Your windows configuration file is named app.config rather than web.config and lives in the bin folder alongside the exe file. Within Visual Studio there is a "top level" AppConfig file that VS copies to the bin folder when you compile. You may need to add the AppConfig file to your project -- it is a special file type in the Add Item dialog.

你的 Windows 配置文件被命名为 app.config 而不是 web.config 并且与 exe 文件一起位于 bin 文件夹中。在 Visual Studio 中,有一个“顶级”AppConfig 文件,VS 会在您编译时将其复制到 bin 文件夹中。您可能需要将 AppConfig 文件添加到您的项目中——它是 Add Item 对话框中的一种特殊文件类型。

+tom

+汤姆

回答by John Saunders

In the above post, that should be "app.config" and "web.config", and the better URL is the one at http://msdn.microsoft.com/en-us/library/ms730064.aspx.

在上面的帖子中,应该是“app.config”和“web.config”,更好的 URL 是http://msdn.microsoft.com/en-us/library/ms730064.aspx