【问题标题】:Dump SOAP as Text to a File将 SOAP 作为文本转储到文件中
【发布时间】:2012-02-02 22:04:39
【问题描述】:

我有一个程序将数据发送到 Web 服务并将数据存储到 XML 文件中。我想知道是否有一个类或方法可以捕获前往服务的肥皂对象并将其转储到文本文件中。谁能告诉我该怎么做?

编辑 1:

好的,所以在浏览了评论中发布的主题后,我编辑了我的 web.config 文件,如下所示:

<?xml version="1.0"?>
<configuration>

<configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
        <section name="XML_New.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
</configSections>
<appSettings>
<add key="username" value="admin"/>
<add key="password" value="admin"/>
</appSettings>
<connectionStrings/>
<system.diagnostics>
<sources>
  <source name="System.ServiceModel.MessageLogging">
    <listeners>
      <add name="messages"
      type="System.Diagnostics.XmlWriterTraceListener"
      initializeData="c:\logs\messages.svclog" />
    </listeners>
  </source>
</sources>
</system.diagnostics>

<system.serviceModel>
<diagnostics>
  <messageLogging logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="420">
    <filters>
      <add nodeQuota="10" 
   xmlns:soap="http://www.w3.org/2003/05/soap-envelope">

/soap:Envelope/soap:Header
      </add>
    </filters>
  </messageLogging>
</diagnostics>
</system.serviceModel>
<system.web>
    <compilation debug="true" >

    </compilation>
<authentication mode="Forms" />
</system.web>
<applicationSettings>
    <XML_New.Properties.Settings>
        <setting name="XML_New_localhost_Service1" serializeAs="String">
            <value>http://localhost:1689/Admin.asmx</value>
        </setting>
    </XML_New.Properties.Settings>
</applicationSettings>
</configuration>

该文件应记录到 c:\logs\messages.svclog 但由于某些原因它没有记录。有人知道为什么吗?

【问题讨论】:

标签: c# asp.net web-services soap


【解决方案1】:

在 asmx 服务级别,您可以使用soap 扩展。此处的文档和工作示例:http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapextension.aspx。您可能可以复制粘贴整个内容,更改GetInitializer 中的转储路径,它可能对您有用。 +1

【讨论】:

  • 实际上,这显然也可以在客户端插入(基于.net/soap)。我自己不知道。我在 asmx 做了很多次;像魅力一样工作。
【解决方案2】:

您可以使用 FiddlerCore 拦截 HTTP 上的 SOAP,并从请求和响应中保存您想要的所有数据。

http://www.fiddler2.com/fiddler/Core/

【讨论】:

    猜你喜欢
    • 2011-11-01
    • 2010-10-10
    • 1970-01-01
    • 1970-01-01
    • 2013-02-08
    • 1970-01-01
    • 2012-01-30
    • 2018-05-25
    • 1970-01-01
    相关资源
    最近更新 更多