.net - 使 WCF 与 netTcpBinding 配合使用时遇到问题

标签 .net wcf nettcpbinding

下面是我的app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="Indexer">
        <endpoint address="net.tcp://localhost:8000/Indexer/" binding="netTcpBinding"
          bindingConfiguration="TransactionalTCP" contract="Me.IIndexer" />
      </service>
      <service name = "Indexer" behaviorConfiguration = "MEXGET">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8000/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name = "MEXGET">
          <serviceMetadata httpGetEnabled = "true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="TransactionalTCP"
           transactionFlow="true"
         />
      </netTcpBinding>
    </bindings>
  </system.serviceModel>
</configuration>

出于某种原因,我无法访问运行此程序的计算机上的 WCF 服务。 任何人都可以发现错误吗?我已启动并运行 netTcpBinding 服务。

当我在 HTTP 中运行相同的内容时,它可以与以下 .config 文件正常工作

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="IndexerServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8080/Indexer/"/>
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="Indexer" behaviorConfiguration="IndexerServiceBehavior">
        <endpoint address="http://localhost:8080/Indexer/" binding="basicHttpBinding"
            bindingConfiguration="" name="HTTP" contract="IIndexer" />
        <endpoint address="http://localhost:8080/Indexer/MEX/" binding="mexHttpBinding"
            bindingConfiguration="" name="MEX" contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>
</configuration>

我真的不知道我做错了什么..

最佳答案

您当然已经打开防火墙让它监听?

如果有任何用处,这是我不久前成功使用的绑定(bind):

<services>

  <service name="MyService.MySearch" behaviorConfiguration="ServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://mypc:8003/MyService"/>
      </baseAddresses>
    </host>
    <endpoint bindingConfiguration="Binding1"
              binding="netTcpBinding"
              contract="MyService.IMySearch"
              address="net.tcp://mypc:8004/MyService"  />
  </service>
</services>
<bindings>
  <netTcpBinding>
    <binding name="Binding1"
             hostNameComparisonMode="StrongWildcard"
             sendTimeout="00:10:00"
             maxReceivedMessageSize="65536"
             transferMode="Buffered"
             portSharingEnabled="false">
      <security mode="None">
        <transport clientCredentialType="None" />
        <message clientCredentialType="None" />
      </security>
    </binding>
  </netTcpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
    </behavior>
  </serviceBehaviors>
</behaviors>

此绑定(bind)没有安全性。

关于.net - 使 WCF 与 netTcpBinding 配合使用时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1344875/

相关文章:

c# - {} 在 linq 结果中

c# - .Net 将 JSON 反序列化为 c# 对象

c# - 如何在 .net 中找到当前线程的最大堆栈大小?

c# - 从 C# WCF 服务返回具有动态维数的锯齿状数组

jquery - 通过 $.ajax 访问 Azure 中的 WCF 会产生 "NETWORK_ERR: XMLHttpRequest Exception 101"

C# WCF NetTCPBinding 阻塞应用程序

c# - 从 .NET 中的数据库图像列将多个文件附加到电子邮件

c# - WSE012 : The input was not a valid SOAP message because the following information is missing: action

WCF - 使用带有 net.tcp 绑定(bind)的 WS-Compression 未关闭套接字连接

wcf - Windows 7和Windows 2008 Server下IIS托管net.tcp wcf服务有什么区别吗?