2010-07-30 101 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