2010-07-30 102 views
1

我已經編寫了在Windows服務中創建了一個WCF服務,出於某種原因我無法弄清楚,我在一堆系統上部署了該服務(在操作系統和配置中幾乎完全相同),並且它適用於除一臺服務器之外的所有設備。除服務的基地址外,所有部署的配置都是相同的。WCF(net.tcp)服務:適用於除一個系統以外的所有系統

當服務啓動時,當我打開ServiceHost,並且使用netstat -anp時,我可以看到服務進程已打開套接字。我爲丟棄的數據包設置了Windows防火牆日誌記錄,但日誌文件仍然爲空。

,如果我嘗試訪問從WCF測試客戶端WCF服務,我得到以下信息:

Error: Cannot obtain Metadata from net.tcp://myhostname:9001/SysMonitorAgent 
If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455. 
WS-Metadata Exchange Error  
    URI: net.tcp://myhostname:9001/SysMonitorAgent  
    Metadata contains a reference that cannot be resolved: 'net.tcp://myhostname:9001/SysMonitorAgent'. 
    There was no endpoint listening at net.tcp://myhostname:9001/SysMonitorAgent that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. 

我試過WCF日誌,但日誌文件甚至不會創建。

該服務的配置如下:

<system.serviceModel> 
    <diagnostics> 
    <messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" /> 
    </diagnostics> 
    <bindings> 
    <netTcpBinding> 
     <binding name="InterfaceServiceNetTcpBinding"> 
     <security mode="None"> 
      <transport clientCredentialType="None" protectionLevel="None" /> 
      <message clientCredentialType="None" /> 
     </security> 
     </binding> 
    </netTcpBinding> 
    </bindings> 
    <behaviors> 
    <serviceBehaviors> 
     <behavior name="InterfaceServiceBehavior"> 
     <serviceMetadata httpGetEnabled="false" /> 
     <serviceDebug httpHelpPageEnabled="false" httpsHelpPageEnabled="false" includeExceptionDetailInFaults="false" /> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 
    <services> 
    <service name="SysMonitor.Agent.Interface.InterfaceService" behaviorConfiguration="InterfaceServiceBehavior"> 
     <endpoint address="" binding="netTcpBinding" bindingConfiguration="InterfaceServiceNetTcpBinding" contract="SysMonitor.Agent.Interface.IInterfaceService"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /> 
     <host> 
     <baseAddresses> 
      <add baseAddress="net.tcp://myhostname:9001/SysMonitorAgent" /> 
     </baseAddresses> 
     </host> 
    </service> 
    </services> 
</system.serviceModel> 

我有點失落,因爲沒有任何跡象,爲什麼它不工作。任何幫助,將不勝感激。

回答

0

在您正在部署的服務器上是否在端口9100上運行?

它似乎無法找到該服務。你有沒有嘗試改變基地址?

典型的,如果你部署它在伺服系統上,它不能在一個它是機器的配置工作。我會檢查

  • .NET版本
  • 確保沒有防火牆是設置本機防止結合
  • 檢查你要綁定的端口是在這種情況下,開放9100
  • 確保任何第三第三方.dll包含在GAC或文件夾中(如果需要)。
  • 驗證所有的.dll和您的代碼是最新的。

我看到錯誤消息稱「的net.tcp:// MYHOSTNAME:9001/SysMonitorAgent」

你嘗試用本機的IP地址來替換它,而不是使用主機名?

+0

我已經檢查過該端口僅被正確的進程使用。 .NET是第4版,安裝在所有機器上。不使用第三方DLL。唯一的防火牆是Windows防火牆,它對使用的TCP端口有例外。所有部署都是從相同的.msi完成的,並且這些文件是相同的。 – ErikHeemskerk 2010-07-30 15:33:12

+0

已修復,這是我的一個愚蠢的錯誤。我嘗試更改端口,然後在運行'netstat -ano'時注意到端口沒有改變。然後我發現我一直在編輯錯誤的配置文件。感謝指針! – ErikHeemskerk 2010-08-02 05:40:04

+0

嘿大衛,我有同樣的問題,我想,並試圖說你說,但沒有工作......你能幫我嗎?這裏是相關的問題:** [問題](http:// stackoverflow。com/questions/9273340/cant-test-net-tcp-service-in-wcftestclient#comment11690979_9273340)** – Joze 2012-02-14 10:04:52

0

除了David的觀點之外,請檢查Windows服務是否正在運行。

事件日誌中的任何錯誤?

+0

服務正在運行,並且「服務已啓動」以外的事件查看器中沒有任何內容。 – ErikHeemskerk 2010-07-30 20:10:05