C# Getting XML SOAP response from autogenerated Reference.cs in Visual Studio

泄露秘密 提交于 2019-12-12 11:18:57

问题


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"

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);

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

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.

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

Edit: 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:


You have following options:

  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.


来源:https://stackoverflow.com/questions/15415607/c-sharp-getting-xml-soap-response-from-autogenerated-reference-cs-in-visual-stud

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!