WCF 调用未显示在 Fiddler2 中

发布于 2024-11-09 01:27:38 字数 1265 浏览 0 评论 0原文

我有一个带有 basicHttp 绑定的简单 WCF 服务。该服务在本地(Win7 笔记本电脑)的 IIS7 中托管。我可以浏览该服务: 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>

I have a simple WCF Service with basicHttp binding. The service is hosted locally (Win7 laptop) in IIS7. I'm able to browse the service at: http://localhost/musicstore/musicstore.svc
(port 80)

I've developed a simple windows form client app to call the service. It works fine but I'd really like to see the message call / response through Fiddler2. Fiddler2 will happily report traffic as I browse the web so I can't understand why it's not picking up this WCF call?

Is there another way to view the data on WCF calls. Maybe there's a Microsoft Tool?

The client config is:

<?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>

The service config is:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

纵性 2024-11-16 01:27:38

查看 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 来完成此操作,其中包含有关您的内容的更多详细信息可以配置。您可以在服务跟踪查看器中查看日志。

The easiest way to see what WCF is doing is to turn WCF's own logging on. You can do this by editing your web.config and adding

<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 has more detailed information on what you can configure. You can view the logs in the Service Trace Viewer.

淡莣 2024-11-16 01:27:38

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

There are many duplicates of this question, many of which have correct answers. You should use http://localhost.fiddler/ as the target and .NET will properly proxy the request. Fiddler will then change "localhost.fiddler" to "localhost" before passing on the request.

书信已泛黄 2024-11-16 01:27:38

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

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

或者您可以使用:

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

来自:Fiddler 站点

You can modify your client's configfile:

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

Or you could use:

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

From: Fiddler site

如歌彻婉言 2024-11-16 01:27:38

我遇到了同样的问题,并通过以下方式修复了它:

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

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

  5. 您可能需要更改 WCF 配置以允许 ASP.NET 4.0 的多个绑定

    ;
    

I had the same problem and fixed it this way:

  1. Host your service in IIS express
  2. Add a binding to your external LAN ip using applicationhost.config of IISExpress in Documents/IISExpress/config
  3. Use the proxy configuration of dutch nico (see below)

  4. Make sure your client application uses your 'external' ip. So 192.168.1.X instead of localhost.

  5. You might have to change your WCF config to allow multiple bindings for asp.net 4.0

    <serviceHostingEnvironment multiplesitebindingsenabled="true"/>
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文