使 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>
我无法真正弄清楚我做错了什么。
Below is my 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>
For some reason, I cannot get to the WCF service on the machine where I run this.
Can any one spot the error? I have netTcpBinding service up and running.
When I had the same running in HTTP it was working fine with the following .config file
<?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>
I can't really figure out what I'm doing wrong..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当然,您已经打开防火墙让它监听?
如果有任何用处,这是我不久前成功使用的绑定:
此绑定没有安全性。
You have, of course, opened up the firewall to let it listen?
If it's any use, here's the binding I successfully used not so long ago:
There's no security on this binding.
您可能必须启用 Net.TCP 端口共享服务。引用自MSDN:
祝你好运!
You may have to Enable the Net.TCP Port Sharing Service. Quote from MSDN:
Good luck!
尝试对 http 和 net.tcp 绑定使用不同的端口号。端口共享有不同的目的,即在多个进程之间共享相同的 net.tcp 端口。
Try using a different port numbers for http and net.tcp binding. Port sharing has a different purpose, to share the same net.tcp port among multiple processes.