我已經編寫了在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>
我有點失落,因爲沒有任何跡象,爲什麼它不工作。任何幫助,將不勝感激。
我已經檢查過該端口僅被正確的進程使用。 .NET是第4版,安裝在所有機器上。不使用第三方DLL。唯一的防火牆是Windows防火牆,它對使用的TCP端口有例外。所有部署都是從相同的.msi完成的,並且這些文件是相同的。 – ErikHeemskerk 2010-07-30 15:33:12
已修復,這是我的一個愚蠢的錯誤。我嘗試更改端口,然後在運行'netstat -ano'時注意到端口沒有改變。然後我發現我一直在編輯錯誤的配置文件。感謝指針! – ErikHeemskerk 2010-08-02 05:40:04
嘿大衛,我有同樣的問題,我想,並試圖說你說,但沒有工作......你能幫我嗎?這裏是相關的問題:** [問題](http:// stackoverflow。com/questions/9273340/cant-test-net-tcp-service-in-wcftestclient#comment11690979_9273340)** – Joze 2012-02-14 10:04:52