从 WCF 创建客户端查看 SOAP XML [英] View SOAP XML from WCF Creating Client
问题描述
我按照以下说明使用 SVCUTIL.exe 创建了 WCF 客户端:http://msdn.microsoft.com/en-us/library/ms733133.aspx
它会创建一个 app.config 和一个 soapproxy.cs 文件来使用.
我想不出任何获取原始 XML 以进行调试的方法.
Google 有很多向 web.config 文件添加 traceextension 的示例,但是我没有 web.config 文件...我找到的示例用于 web.service 而不是 System.ServiceModel;
我需要访问 XML soap 调用以便调试它吗?
更新:我正在尝试编辑配置跟踪以查看 SOAP XML.
我已将此添加到 app.config 文件中
<预><代码><配置><系统诊断><来源><源名称="System.ServiceModel"switchValue="信息,活动跟踪"传播活动=真"><听众><add name="xml"/></听众></来源><source name="CardSpace"><听众><add name="xml"/></听众></来源><源名称="System.IO.Log"><听众><add name="xml"/></听众></来源><源名称="System.Runtime.Serialization"><听众><add name="xml"/></听众></来源><源名称="System.IdentityModel"><听众><add name="xml"/></听众></来源></来源><sharedListeners><添加名称=xml"type="System.Diagnostics.XmlWriterTraceListener"initializeData="c:\log\Traces.svclog"/></sharedListeners></system.diagnostics></配置>但是出现的跟踪日志似乎不包含原始 XML
为了快速调试,我使用 WCF 测试客户端.它非常简单,适用于 WCF 和 ASMX 服务.我还用它来消费用 Java 编写的第三方应用程序的服务(带有 wsdl 定义).
开始 ->Visual Studio 2010 命令提示符 ->wcftestclient.exe
或
开始 ->Visual Studio 2008 命令提示符 ->wcftestclient.exe
此处的信息:http://msdn.microsoft.com/en-我们/图书馆/bb552364.aspx
这可以查看 XML/SOAP 请求和响应.
我也使用 XMLTraceListener.这会在我的应用程序路径中为我生成跟踪,我可以查看整个请求/响应正文.
这是我的 web.Config 部分
<来源><source name="System.ServiceModel" switchValue="All"><听众><add name="xmlTraceListener"/></听众></来源><source name="System.ServiceModel.MessageLogging" switchValue="All"><听众><add name="xmlTraceListener"/></听众></来源></来源><sharedListeners><add name="xmlTraceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="ApplicationTrace.svclog"/></sharedListeners><trace autoflush="true"/></system.diagnostics>
I have created a WCF Client with the SVCUTIL.exe following these instructions : http://msdn.microsoft.com/en-us/library/ms733133.aspx
It creates a app.config and a soapproxy.cs file to use.
I can not figure out any way of getting the raw XML for debugging purposes.
Google has lots of examples with adding a traceextension to the web.config file, however I do not have a web.config file... And the examples I found are for web.service not System.ServiceModel;
I need to access the XML soap calls so I can debug it?
UPDATE: I am trying to edit the config trace to view the SOAP XML.
I have added this to the app.config file
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="CardSpace">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="System.IO.Log">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="System.Runtime.Serialization">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="System.IdentityModel">
<listeners>
<add name="xml" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\log\Traces.svclog" />
</sharedListeners>
</system.diagnostics>
</configuration>
However the trace log that comes up does not seem to include the raw XML
For quick debugging I use the WCF Test Client. Its quite simple and works with WCF and ASMX services. I also use it to consume services from third party applications written in Java (with wsdl definitions).
Start -> Visual Studio 2010 Command Prompt -> wcftestclient.exe
or
Start -> Visual Studio 2008 Command Prompt -> wcftestclient.exe
Information here: http://msdn.microsoft.com/en-us/library/bb552364.aspx
This has the ability to view the XML/SOAP request and response.
Also I use the XMLTraceListener. This generates the trace for me inside my application path and I am able to view the entire request/response body.
Here is my web.Config section
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="All">
<listeners>
<add name="xmlTraceListener" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="All">
<listeners>
<add name="xmlTraceListener" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xmlTraceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="ApplicationTrace.svclog" />
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
这篇关于从 WCF 创建客户端查看 SOAP XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!