【发布时间】:2014-02-23 21:24:27
【问题描述】:
我是 wcf 的新手。所以经常阅读 wcf 上许多站点的基本教程和指南。我看到人们用[OperationContract(IsOneWay=true)]等特殊属性设计他们的wcf服务
[ServiceContract]
public interface IArticleService
{
[OperationContract(IsOneWay=true)]
void OneWayMethod();
}
在阅读了这个单向操作之后,我明白了它是什么...... 当一个操作没有返回值,并且客户端不关心调用的成功或失败。 WCF 提供单向操作来支持这种即发即弃的调用:一旦客户端发出调用,WCF 就会生成请求消息,但不会返回任何相关的回复消息给客户端
我想知道如果我没有指定 IsOneWay=true 或 IsOneWay=false 那么 IsOneWay=true 是默认值。告诉我当我们不指定这个属性 IsOneWay=true 时会发生什么?
或像 IsOneWay=false 一样指定
谢谢
更新
我从这个网址 http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontractattribute.isoneway%28v=vs.110%29.aspx 阅读了一篇文章并理解 IsOneWay=true 或 IsOneWay=false 的含义
[ServiceContract]
public class OneAndTwoWay
{
// The client waits until a response message appears.
[OperationContract]
public int MethodOne (int x, out int y)
{
y = 34;
return 0;
}
// The client waits until an empty response message appears.
[OperationContract]
public void MethodTwo (int x)
{
return;
}
// The client returns as soon as an outbound message
// is queued for dispatch to the service; no response
// message is generated or sent.
[OperationContract(IsOneWay=true)]
public void MethodThree (int x)
{
return;
}
}
【问题讨论】:
标签: wcf