IsOneWay [英] IsOneWay

查看:68
本文介绍了IsOneWay的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如我在前面的线程中所解释的,我正在做一个WCF服务,该服务接受对象并将它们添加到列表中.我还做了一个删除所有对象的函数(List< MyObjects> listOfMyObjects; listOfMyObjects.Clear();).

As I've explained in previous threads I'm doing a WCF service that takes in objects and adds them to a list. I also made a function that removes all objects (List<MyObjects> listOfMyObjects; listOfMyObjects.Clear();).

在我的界面中,我已经这样定义了

in my interface I've defined it like that

[OperationContract(IsOneWay = true)]
避免RemoveAllObjects();

[OperationContract(IsOneWay=true)]
void RemoveAllObjects();

问题是,IsOneWay会这样做:

The things is, IsOneWay does this:

>>如果您未使用IsOneWay标记操作",那么我们将等待ACK/NACK答复

>> if you don’t mark the Operation with IsOneWay then we will wait for an ACK/NACK reply

因此,就我而言,它不会返回回复消息.但是对于我的客户端应用程序来说,在调用此函数后知道所有对象已被删除是至关重要的.因此,我可以删除((IsOneWay = true)")一切都应该没问题,但是我有了一个函数,该函数被调用并且不返回任何内容.

So, in my case, it doesn't return a reply message. But it is crucial for my application on the client side to know that all objects have been removed, after calling this function. So, I could just erase "(IsOneWay=true)" and all should be fine, but then I have an function, that is called and doesn't return anything.

这是完全错误的吗?如果我有一个void方法,并且未将其定义为IsOneWay,我会失去WCF的基本概念吗?

Is this terribly wrong? Will I lose the basic idea of WCF if I have a void method and don't define it as IsOneWay?

推荐答案

如果您希望客户端收到任何形式的答复,IsOneWay必须为假.您可以执行以下操作之一:
If you want the client to receive any sort of reply, IsOneWay needs to be false. You could do one of the following:
-如果删除操作失败,则会从服务中引发错误.您将不得不在客户端上抓住这一点.如果呼叫没有返回错误,则可以假定您的列表现在为空*.
 - throw a fault from the service if your remove operation fails. you would have to catch this on the client. If the call doesn't return a fault you can assume your List is now empty*.


这篇关于IsOneWay的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆