C#从Visual Studio中自动生成的Reference.cs获取XML SOAP响应 [英] C# Getting XML SOAP response from autogenerated Reference.cs in Visual Studio

查看:434
本文介绍了C#从Visual Studio中自动生成的Reference.cs获取XML SOAP响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用.net 3.5的Visual Studio 2008中,我使用了WSDL,该WSDL自动生成了Reference.cs. 通过右键单击我项目中的引用"并选择添加Web引用"来完成此操作

In visual studio 2008 using .net 3.5 i have consumed a WSDL which has automatically generated a Reference.cs. This was done by right clicking on References in my project and selecting "Add Web Reference"

使用此方法,我可以发布到Web服务并通过我的ref和out对象获得有效的响应. postValues()是一个无效方法.

Using this i can post to the web service and get valid responses through my ref and out objects. postValues() is a void method.

webService.postValues(ref value1, ref value2, out value3);

使用WireShark,我可以在网络上看到请求和完整的肥皂响应.

Using WireShark i can see the the request and full soap response on my network.

我想弄清楚的是如何在代码中捕获此原始SOAP响应. 我想捕获此数据用于日志记录目的,而不是单独序列化每个ref对象.

What im trying to figure out is how can i capture this raw SOAP response in my code. I would like to capture this for logging purposes and would rather not individually serialize each of the ref objects.

无论如何,我看不到在不修改自动生成的Reference.cs的情况下执行此操作,而ID却不这样做. 任何帮助,将不胜感激.

I cant see anyway to do this without modifying the automatically generated Reference.cs which id rather not do. Any help would be appreciated.

我似乎没有办法做到这一点.其他人可以确认或否认吗?

There doesnt seem to be a way to do this that i can see. Can anyone else confirm or deny this?

编辑.这让我再难过一次,看看是否有人知道.

EDIT. Ill bump this just one more time to see if anyone knows.

推荐答案

您有以下选择:

  1. 启用跟踪在配置中用于您的Web服务,并将所有信息转储到文件中.如果您使用的是WCF而不是旧版Web服务,请在如何为WCF启用跟踪.
  2. 实施您自己的SoapExtension 并插入到消息处理管道中,以拦截和转储传入/传出的肥皂消息.我认为链接动脉中的示例包含TraceExtension,它确实可以做到这一点.
  3. 按照您的指定修改生成的Reference.cs并转储传递的对象.
  1. Enable tracing for your web service in config, and dump all information into file. If you are using WCF instead of legacy web services, see this question on how to enable tracing for WCF.
  2. Implement your own SoapExtension and plug into message processing pipeline to intercept and dump incoming/outgoing soap messages. I think example in linked artice contain TraceExtension, which does exactly that.
  3. Modify generated Reference.cs and dump passed objects, as you specified.

这篇关于C#从Visual Studio中自动生成的Reference.cs获取XML SOAP响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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