2011-05-23 25 views
9

我有一個簡單的WCF服務與basicHttp綁定。該服務在IIS7本地託管(Win7筆記本電腦)。我可以瀏覽以下服務:http://localhost/musicstore/musicstore.svc (端口80)WCF調用不顯示在Fiddler2

我開發了一個簡單的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> 

回答

15

,看看有什麼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中的日誌。

+0

這是一種享受!謝謝。 – 2011-05-23 17:12:14

3

您可以通過修改客戶端的CONFIGFILE:

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

或者你可以使用:

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

來源:Fiddler site

+0

嗯,這似乎沒有任何區別:( – 2011-05-23 16:58:34

+2

+1 Fiddler充當網絡代理,所以任何不使用代理將不會被檢測到。WCF,默認情況下不會。 – CodingWithSpike 2011-05-23 16:59:32

+0

在提供的網址,可以使用其他選項來實現這種情況 – 2011-05-23 17:00:46

0

我有同樣的問題,並固定它是這樣的:

  1. 主機服務在IIS中表達
  2. 使用IISExpress的對ApplicationHost.config文件中添加綁定到外部網絡的IP/IISExpress /配置
  3. 使用荷蘭尼科的代理配置(見下文)

  4. 製作確定你的客戶端應用程序使用你的'外部'IP。所以192.168.1.X而不是localhost。

  5. 您可能需要改變你的WCF配置爲允許多個綁定asp.net 4.0

    <serviceHostingEnvironment multiplesitebindingsenabled="true"/> 
    
8

有此問題的很多重複,其中有許多正確的答案。您應該使用http://localhost.fiddler/作爲目標,.NET將正確代理請求。在傳遞請求之前,Fiddler會將「localhost.fiddler」更改爲「localhost」。