我跟着这个教程(至少根据我的WCF在此,怎么我需要再上班一样): http://www.eggheadcafe.com/tutorials/wcf/b5ada8df-58c5-492f-b368-457b3a4f137c/notify-client-applications-using-wcf-callbacks.aspx如何通过互联网使用WCF双重服务?
它的工作非常好我的电脑上,但我需要使用它在互联网上。在尝试这样做时,我听说(通过互联网)最好使用netTcpBiding。
我会有一个服务器,要知道在线客户端的数量。我想在服务器上的IIS上使用WFC服务,并且需要一个Windows服务使用它并通知它。我需要回调服务器有时必须能够在客户端执行一些命令。
如果有人能帮助我,我会非常高兴。
由于提前,
编辑:
说明白了:我只是不能让它工作在互联网上。你们可以告诉我如何更改我的配置(Web.config和App.config)以使用netTcpBinding并通过互联网工作?再次
感谢,
编辑2:
我在我的WCFServiceApplication Web.config文件是:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IPCWatcherWCFService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="TiT.PCWatcher.Server.WCFService.Services.PCWatcherWCFServiceBehavior" name="TiT.PCWatcher.Server.WCFService.Services.PCWatcherWCFService">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IPCWatcherWCFService" contract="TiT.PCWatcher.Server.WCFService.Interfaces.IPCWatcherWCFService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TiT.PCWatcher.Server.WCFService.Services.PCWatcherWCFServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
我的App.config我WindowsService是:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IPCWatcherWCFService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:25145/Services/PCWatcherWCFService.svc"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IPCWatcherWCFService"
contract="PCWatcherWCFServiceReference.IPCWatcherWCFService"
name="WSDualHttpBinding_IPCWatcherWCFService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
只是将其更改为netTcpBinding不起作用...
但是我很高兴能够通过互联网运行此...我在IIS上发布了WCFService。链接:
https://www2.tcenter.com.br/monitor/PCWatcherWCFService.svc
OR
http://www2.tcenter.com.br:8080/monitor/PCWatcherWCFService.svc
只是改变了其CONFIGS足够多,使其通过互联网工作?就像我说的那样,本地它工作得很好。
我以为只是改变了客户端上的端点地址URL的一个它上面工作对子级,但它没有...
你的主机挂在WPF服务的例子。我不知道它是否适用于我的日记...
我想我会坚持使用DualHttpBinding,你不认为端口转发它对我的需求很好,我可以有很多的客户在一个内部网中,并让路由器决定他要发送信息,因为它不是正确的?或者有一种方法可以使路由器对通过同一端口连接到我的网络服务器的每台机器进行相应的响应?!(只是问,呵呵呵)
非常感谢提前,
编辑于21/06/2012:
感谢您的阅读。 我无法获得与LAN中的netTcpBinding一起使用的服务。 我做了一个模拟样本,我的纪念日。这是here。称为DualCommunicationTest。
当我开始这篇文章时,我只是想知道如何使这个cenarion在互联网上运行。只是。 在我发布这篇文章之前,我在寻找解决方案的时候,我认为netTcpBinding更好。所以我问了一下。这只是一个侧面的问题。
所以......我的帖子目前的需求是:
如何在互联网上使用the sample i developed。
OR
如何使the sample i developed工作,NetTcpBinding的,然后可以使用它在互联网上。 (我很确定Clunky Coder教会了我第二部分,关于如何在IIS上发布net.tcp和其他内容,非常感谢,但是我还没有测试它,因为我不能测试它, t做一个netTcp呢。)
对不起,如果我不够清楚,我的英语不太好。谢谢,很多。
不错的阅读确实...好吧,我不知道如果我去netTcp或wsDual,但是,你能帮我把它工作吗?我很高兴只是把上面的链接中实现的例子工作... –
@TanielianBarreira,我只是看了文章,似乎写得很好,问题到底是什么?它通过它的外观实现了一个简单的聊天服务,在WCF中有很多关于回调的例子。这个想法的要点是客户端调用服务的某些操作,而服务又可以调用客户端的一个方法(这是回调),所以客户端将暂时像服务器本身一样。 ChatService中的方法是客户端在服务器上调用的,IChatServiceCallback中的方法是服务在客户端上调用的方法。 –
@TanielianBarreira看看我的更新。 –