【发布时间】:2013-10-03 15:06:25
【问题描述】:
我安装了一个 Windows 应用程序,它使用 WCF 服务,我只是通过以下配置通过 Windows 服务中托管的 net tcp 绑定查看 WCF 服务的配置文件,我想知道客户端如何使用这个 WCF服务。应用程序使用此服务在 UI 中填充数据,并且它可以工作。当我尝试使用它时,我无法通过 WCF 测试客户端这样做。那么应用如何消费这个服务呢?
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_FirstBindingServiceContract" closeTimeout="00:10:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="999999999" maxBufferSize="999999999" maxConnections="10"
maxReceivedMessageSize="999999999">
<readerQuotas maxDepth="999999999"
maxStringContentLength="999999999"
maxArrayLength="999999999"
maxBytesPerRead="999999999"
maxNameTableCharCount="999999999" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehaviors">
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="MyService.DataAccessService" behaviorConfiguration="MyServiceBehaviors">
<endpoint bindingConfiguration="NetTcpBinding_FirstBindingServiceContract"
name="firstBinding" address="net.tcp://localhost:25488/MyDataAccessService/MyFirstBindingAddress"
binding="netTcpBinding"
contract="MyDataService.IMyDataAccessService">
</endpoint>
</service>
</services>
</system.serviceModel>
【问题讨论】:
-
如果调用应用程序知道所有参数(地址、绑定、合约),那么它可以轻松调用该服务......
-
由于您使用的是 net.tcp,我们可以假设它是 .Net 到 .Net 的通信(即不可互操作)。 WCF 允许您“使用共享合同”来生成您的代理。 I.o.w.您可以设置对服务器用来实现服务的接口库的引用。不要设置对具有具体类型的库的引用,而只能设置对接口的引用。
标签: wcf nettcpbinding