2

下面是我的 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>

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

4

3 回答 3

3

当然,你已经打开了防火墙让它听?

如果有什么用,这是我不久前成功使用的绑定:

<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>

此绑定没有安全性。

于 2009-08-28T03:41:31.103 回答
1

您可能必须启用 Net.TCP 端口共享服务。引用 MSDN:

Windows Communication Foundation (WCF) 使用称为 Net.TCP 端口共享服务的 Windows 服务来促进跨多个进程共享 TCP 端口。此服务作为 WCF 的一部分安装,但作为安全预防措施,默认情况下未启用该服务,因此必须在首次使用之前手动启用。本主题介绍如何使用 Microsoft 管理控制台 (MMC) 管理单元配置 Net TCP 端口共享服务。

祝你好运!

于 2009-08-28T03:37:40.890 回答
0

尝试为 http 和 net.tcp 绑定使用不同的端口号。端口共享有不同的目的,在多个进程之间共享同一个 net.tcp 端口。

于 2009-08-28T03:58:33.330 回答