简体   繁体   English

如何使用TCP / IP双工连接创建简单的WCF服务?

[英]How to create a simple WCF service with a TCP/IP duplex connection?

I'm trying to learn how to create a web service that is capable of both sending and receiving data. 我正在尝试学习如何创建能够发送和接收数据的Web服务。
As an example I have defined a ServerTimeService: 例如,我定义了ServerTimeService:

[ServiceContract]
public interface ServerTimeService
{
    [OperationContract]
    DateTime GetServerTime();

    [OperationContract(IsOneWay = false)]
    DateTime SendServerTime();
}

Now I am told I should be providing a callback contract, but I really don't get why or what it is? 现在,我被告知我应该提供一个回调合同,但是我真的不知道为什么还是什么? When is the callback contract called? 回调合约什么时候调用?
Further more I'd like to see a code exmple sending the server time and receiving it at the client. 更进一步,我想看到一个示例代码,它发送服务器时间并在客户端接收它。

Here's another simple duplex example that outlines the basics pretty well. 这是另一个简单的双工示例,很好地概述了基础知识。 An example project is included. 其中包括一个示例项目。 http://realfiction.net/2008/01/30/the-no-frills-bare-bones-example-to-duplex-wcf http://realfiction.net/2008/01/30/the-no-frills-bare-bones-example-to-duplex-wcf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM