【问题标题】:WCF Call not showing in Fiddler2WCF 调用未在 Fiddler2 中显示
【发布时间】:2011-05-23 16:35:14
【问题描述】:

我有一个带有 basicHttp 绑定的简单 WCF 服务。该服务在 IIS7 中本地托管(Win7 笔记本电脑)。我可以在以下位置浏览服务:http://localhost/musicstore/musicstore.svc (端口 80)

我开发了一个简单的 Windows 窗体客户端应用程序来调用该服务。它工作正常,但我真的很想通过 Fiddler2 看到消息调用/响应。当我浏览网页时,Fiddler2 会很高兴地报告流量,所以我不明白为什么它没有接听这个 WCF 调用?

还有其他方法可以查看 WCF 调用的数据。也许有一个微软工具?

客户端配置为:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>

    <client>
      <endpoint address="http://localhost/musicstore/musicstore.svc"
        binding="basicHttpBinding" bindingConfiguration="" contract="MusicStore.IMusicStore"
        name="BasicHttp" />
    </client>
  </system.serviceModel>
</configuration>

服务配置为:

<services>
   <service behaviorConfiguration="MusicStoreBehavior" name="MusicStore">
    <endpoint address="" binding="basicHttpBinding" contract="IMusicStore">
     <identity>
      <dns value="localhost" />
     </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
   </service>
  </services>

【问题讨论】:

    标签: wcf fiddler


    【解决方案1】:

    查看 WCF 正在做什么的最简单方法是打开 WCF 自己的日志记录。您可以通过编辑您的 web.config 并添加来做到这一点

    <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="false"
             logMessagesAtServiceLevel="true" 
             logMessagesAtTransportLevel="false"
             maxMessagesToLog="3000"
             maxSizeOfMessageToLog="2000"/>
      </diagnostics>
    </system.serviceModel>
    

    MSDN 提供有关您可以配置的内容的更详细信息。您可以在Service Trace Viewer查看日志。

    【讨论】:

      【解决方案2】:

      这个问题有很多重复,其中许多有正确的答案。您应该使用http://localhost.fiddler/ 作为目标,.NET 将正确代理请求。 Fiddler 将在传递请求之前将“localhost.fiddler”更改为“localhost”。

      【讨论】:

        【解决方案3】:

        您可以修改客户端的配置文件:

        <configuration>
          <system.net>
            <defaultProxy>
              <proxy bypassonlocal="false" usesystemdefault="true" />
            </defaultProxy>
          </system.net>
        </configuration>
        

        或者你可以使用:

        GlobalProxySelection.Select = new WebProxy("127.0.0.1", 8888);
        

        发件人:Fiddler site

        【讨论】:

        • 嗯,这似乎没有任何区别:(
        • +1 Fiddler 充当 Web 代理,因此不会检测到任何不使用代理的东西。默认情况下,WCF 不会。
        • 在提供的 url 上,可以使用其他选项来使此方案正常工作
        【解决方案4】:

        我遇到了同样的问题并以这种方式解决了它:

        1. 在 IIS express 中托管您的服务
        2. 在 Documents/IISExpress/config 中使用 IISExpress 的 applicationhost.config 添加绑定到您的外部 LAN ip
        3. 使用荷兰nico的代理配置(见下文)

        4. 确保您的客户端应用程序使用您的“外部”IP。所以 192.168.1.X 而不是 localhost。

        5. 您可能必须更改 WCF 配置以允许 asp.net 4.0 的多个绑定

          <serviceHostingEnvironment multiplesitebindingsenabled="true"/>
          

        【讨论】:

          猜你喜欢
          • 2020-01-26
          • 1970-01-01
          • 1970-01-01
          • 2012-06-16
          • 2014-05-04
          • 2021-10-22
          • 1970-01-01
          • 2016-12-18
          • 1970-01-01
          相关资源
          最近更新 更多