如何设置 WCF Net.Tcp [英] How to setup WCF Net.Tcp
问题描述
我正在尝试设置 wcf 服务以通过 IIS 7 使用 net.tcp.
I'm trying to setup a wcf service to use net.tcp over IIS 7.
这是我得到的错误:
没有端点监听net.tcp://127.0.0.1:8000/ListingService可以接受消息.这是通常由错误的地址引起或 SOAP 操作.见内部异常,如果目前,了解更多详情.
There was no endpoint listening at net.tcp://127.0.0.1:8000/ListingService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
这是我从客户端调用的代码:
Here is the code I call from the client:
using (var client = new ListingServiceClient("NetTcpBinding"))
{
client.Test();
client.Close();
}
这是我的服务 web.config - http://pastebin.com/3S8BZbup
Here is my services web.config - http://pastebin.com/3S8BZbup
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding portSharingEnabled="true">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<!--throttle service-->
<serviceThrottling
maxConcurrentCalls="10000"
maxConcurrentSessions="10000"
maxConcurrentInstances="10000" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="default" name="Housters.Services.ListingService">
<endpoint name="TcpEndpoint"
address="net.tcp://127.0.0.1:8000/ListingService"
binding="netTcpBinding"
contract="Housters.Services.IListingService" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
这是我的客户端 app.config - http://pastebin.com/YpiAhh46
And here is my client app.config - http://pastebin.com/YpiAhh46
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint
address="net.tcp://127.0.0.1:8000/ListingService"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding"
contract="ListingServiceProxy.IListingService" name="NetTcpBinding" />
</client>
</system.serviceModel>
有什么想法吗?
推荐答案
此配置在 IIS/WAS 中不起作用.在 IIS 中托管时,您需要 .svc 文件(或 WCF 4 中基于配置的激活),并且端点的地址始终为 VirtualDirectoryPath + SvcFile + 端点配置中指定的相对地址.在端点配置中设置绝对地址用于自托管.
This configuration will not work in IIS/WAS. When hosting in IIS you need .svc file (or configuration based activation in WCF 4) and address of the endpoint is always VirtualDirectoryPath + SvcFile + Relative address specified in endpoint configuration. Setting absolute address in endpoint configuration is for self hosting.
这篇关于如何设置 WCF Net.Tcp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!