我的WCF服务无法运行,因为目标计算机主动拒绝它127 ...:6414

时间:2014-02-26 14:29:04

标签: wcf

我正在使用VS2012。

我做了一个简单的服务,我昨天跑了,它工作正常。

但是现在我再次这样做,只是为了审查它,而且我感到意外的是它不起作用。

不知道为什么机器会主动拒绝它......:6414。

该服务在本地运行,在同一台计算机上运行,​​VS 2012以管理员身份运行。

这是完整的错误:

"There was an error downloading 'http://localhost:6414/HostDevServer/HelloWorldService.svc'. Unable to connect to the remote server. No connection could be made because the target machine actively refused it 127...:6414"

我试图在防火墙中制作入站规则,但没有用。

尝试停用Microsoft Security Essentials,但无效。

尝试在其他机器上完成所有操作,同样的错误。

尝试更改端口号,但无效。

我用Google搜索,我发现的不适合我。

服务非常简单,Web.Config中的ServiceModel定义是:

<system.serviceModel>
    <serviceHostingEnvironment >
        <serviceActivations>
            <add factory="System.ServiceModel.Activation.ServiceHostFactory"
                 relativeAddress="./HostDevServer/HelloWorldService.svc"
                 service="MyWCFServices.HelloWorldService"/>
        </serviceActivations>
    </serviceHostingEnvironment>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceMetadata httpGetEnabled="true"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

该服务由控制台应用程序构成,托管在使用IIS Express的新网站中,所有这些都在同一解决方案中。

HostDevServer的属性页是:

enter image description here

enter image description here

当我运行它时,WCF测试客户端会抛出错误:

enter image description here

它可能是什么?

2 个答案:

答案 0 :(得分:0)

我下载了你的项目并在我的机器上运行它没有任何问题。如果您的问题始终发生,则表示您的计算机没有侦听指定端口的服务,或者有防火墙阻止您。尝试转动防火墙。

您是否尝试仅调试您的网络服务项目?如果是,请告诉我您是否可以访问以下URL:http://localhost:PORT_NUMBER/HostDevServer/HelloWorldService.svc,其中PORT_NUMBER是您为解决方案中的服务器配置的端口。尽量不要使用端口80,它通常用于其他应用程序。由于编译时出现问题,您的服务可能无法启动,因此您可以尝试从bin目录中删除所有 .pdb 文件。

请尝试修改您的web.config。将 system.serviceModel 标记替换为以下内容:

<system.serviceModel>
    <serviceHostingEnvironment >
        <serviceActivations>
            <add factory="System.ServiceModel.Activation.ServiceHostFactory"
                 relativeAddress="./HostDevServer/HelloWorldService.svc"
                 service="MyWCFServices.HelloWorldService"/>
        </serviceActivations>
    </serviceHostingEnvironment>
    <behaviors>
        <serviceBehaviors>
            <behavior name="metadataBehavior">
                <serviceMetadata httpGetEnabled="true"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
      <service name="MyWCFServices.HelloWorldService" behaviorConfiguration="metadataBehavior">
        <endpoint
            address="" binding="basicHttpBinding" contract="MyWCFServices.IHelloWorldService"/>
        <endpoint
            address="mex"
            binding="mexHttpBinding"
            contract="IMetadataExchange"/>
      </service>
    </services>
</system.serviceModel>

答案 1 :(得分:0)

在VS2012中,打开“HostDevServer” - &gt;属性窗口( F4 )并检查Developer Web Server.URL(http://localhost:<Port Number>)上使用的端口,然后确保属性页( Shift + F4 )。启动选项...。​​启动URL:打开并设置为

http://localhost:<Port Number>/HostDevServer/HelloWorldService.svc