我已经编写了在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