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