简体   繁体   English

无法使用NET.TCP绑定访问WCF服务

[英]Unable to access WCF service using NET.TCP binding

I already asked a similar question here: Unable to add service client for a net.tcp WCF service . 我在这里已经问了一个类似的问题: 无法为net.tcp WCF服务添加服务客户端 The problem was solved at that time. 那个问题在那个时候解决了。 But now the same error is coming up. 但现在出现同样的错误。 My configuration of WCF service is same as that of previous question. 我的WCF服务配置与上一个问题的配置相同。 I am again posting it here: 我再次在这里发帖子:

<system.serviceModel>
    <services>
      <service name="CoreService.Service1" behaviorConfiguration="beh1">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost/Service1.svc/mex" />
          </baseAddresses>
        </host>
        <endpoint
     binding="netTcpBinding"
     bindingConfiguration="ultra"
     contract="CoreService.IAccountService"/>
        <endpoint
      binding="netTcpBinding"
      bindingConfiguration="ultra"
      contract="CoreService.IBoardService"/>
        <endpoint
      binding="netTcpBinding"
      bindingConfiguration="ultra"
      contract="CoreService.ICategoryService"/>

        <endpoint
                address="mex"
                binding="mexTcpBinding"
                contract="IMetadataExchange"/>
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name="ultra"
             maxBufferPoolSize="2147483647"
             maxBufferSize="2147483647"
             maxReceivedMessageSize="2147483647"
             portSharingEnabled="false"
             transactionFlow="false"
             listenBacklog="2147483647"
             sendTimeout="00:01:00">
          <security mode="None">
            <message clientCredentialType="None"/>
            <transport protectionLevel="None" clientCredentialType="None"/>
          </security>
          <reliableSession enabled="false"/>
        </binding>
      </netTcpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="beh1">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="True" />
          <dataContractSerializer maxItemsInObjectGraph="65536" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

The error is: 错误是:

The URI prefix is not recognized. 无法识别URI前缀。 Metadata contains a reference that cannot be resolved: 'net.tcp://localhost/Service1.svc'. 元数据包含无法解析的引用:'net.tcp://localhost/Service1.svc'。 Could not connect to net.tcp://localhost/Service1.svc. 无法连接到net.tcp://localhost/Service1.svc。 The connection attempt lasted for a time span of 00:00:02.0051147. 连接尝试持续时间跨度为00:00:02.0051147。 TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:808. TCP错误代码10061:无法建立连接,因为目标计算机主动拒绝它127.0.0.1:808。 No connection could be made because the target machine actively refused it 127.0.0.1:808 If the service is defined in the current solution, try building the solution and adding the service reference again. 无法建立连接,因为目标计算机主动拒绝它127.0.0.1:808如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用。

After the problem was solved, I didn't made any changes to the configuration and after some days it started showing that error again. 问题解决后,我没有对配置进行任何更改,几天后它又开始显示错误。 I tried everything but nothing worked. 我尝试了一切但没有任何效果。 Please help! 请帮忙!

UPDATE : I am also able to access it using HTTP through my browser but unable to access using "Add Service Reference" option through net.tcp protocol. 更新 :我也可以通过浏览器使用HTTP访问它,但无法通过net.tcp协议使用“添加服务引用”选项进行访问。

Finally with the help of this link: http://rohitguptablog.wordpress.com/2011/06/16/configuring-wcf-service-with-nettcpbinding/ , I figured out what was going wrong. 最后借助这个链接: http//rohitguptablog.wordpress.com/2011/06/16/configuring-wcf-service-with-nettcpbinding/ ,我弄清楚出了什么问题。 Actually I missed the third step in above link. 其实我错过了上面链接的第三步。 The Net.Tcp services were not running. Net.Tcp服务未运行。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM