.NET日志或查看SOAP WebService的呼叫/响应 [英] .NET Log or View Call / Response of a SOAP WebService

查看:134
本文介绍了.NET日志或查看SOAP WebService的呼叫/响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检查电话的最佳方法是什么? .NET中的Web服务的响应?

我正在与Perl编写的Web服务进行交互,并遇到问题。

如何捕获调用和响应的文本?



更新:

根据意见澄清:
我想通过.NET,所以我可以在发生问题时进行登录或发送电子邮件。

解决方案

可以通过创建一个 SoapExtension 并在您的Web服务客户端启用它:


System.Web.Services.Protocols.SoapExtension类(MSDN)


上面的链接提供了一个示例代码的框架,用于记录文件的请求/响应。



要在您的应用程序中启用,请将以下内容添加到您的web.config或app.config中:

 < webServices> 
< soapExtensionTypes>
< add type =YourNamespace.TraceExtension,AssemblyName
priority =0group =High/>
< / soapExtensionTypes>
< / webServices>

我自己的SOAP跟踪扩展在其自己的项目/程序集中实现。每当我需要调试请求/响应时,我只需将DLL放在应用程序文件夹(/ bin for ASP.NET)中,并添加对上述配置文件的引用。



例如:

 < webServices> 
< soapExtensionTypes>
< add
type =DebugTools.SOAP.SOAPTrace.SoapTraceExtension,DebugTools.SOAP
priority =0group =High/>
< / soapExtensionTypes>
< / webServices>

DebugTools.SOAP.SOAPTrace 是命名空间的 SoapTraceExtension

DebugTools.SOAP 是包含soap跟踪代码的程序集的名称。


What is the best way to inspect the calls & responses from a web service in .NET?
I'm interacting with a Web Service written in Perl and running into issues.
How can I capture the text of the call and response?

UPDATE:
Based on comment to clarify: I'd like to do it via .NET so I can log it or email it when an issue arises.

解决方案

You can do this by creating a SoapExtension and enabling it in your web service client:

System.Web.Services.Protocols.SoapExtension Class (MSDN)

The link above provides a skeleton of sample code that logs requests/responses to a file.

To enable in your application add the following to your web.config or app.config:

<webServices>
    <soapExtensionTypes>
        <add type="YourNamespace.TraceExtension, AssemblyName" 
             priority="0" group="High"/>
    </soapExtensionTypes>
</webServices>

My own SOAP tracing extension is implemented in its own project/assembly. Whenever I need to debug the request/response I just drop the DLL in the application folder (/bin for ASP.NET) and add the reference to the config file as above.

For example:

<webServices>
   <soapExtensionTypes>
      <add 
         type="DebugTools.SOAP.SOAPTrace.SoapTraceExtension, DebugTools.SOAP" 
         priority="0" group="High"/>
   </soapExtensionTypes>
</webServices>

DebugTools.SOAP.SOAPTrace is the namespace of the SoapTraceExtension
DebugTools.SOAP is the name of the assembly containing the soap trace code.

这篇关于.NET日志或查看SOAP WebService的呼叫/响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆