WCF想要实现客户端进度更新
我有一个双工 WCF 服务,客户端连接到该服务并等待命令。该应用程序的结构如下。
GUI(Asp.net)------------>WCF 服务-------------------->WCF 客户端
来自 Asp.net 页面您可以运行 Gallio/MB 单元测试。这些被传递给服务,服务要求客户端运行测试。一切都运转良好。我现在想要实现的是使用测试状态更新 Asp.net 应用程序。
因此,如果用户想要运行整个测试集,至少我应该知道 Asp.NET 应用程序正在运行哪个测试以及可能已完成的测试的百分比。
非常感谢任何有关如何进行此操作/采取什么方法的帮助。
谢谢
I have a duplex WCF service that clients connect to and wait for commands. The structure of the application is as below.
GUI(Asp.net)------------>WCF Service------------------>WCF Client
The from Asp.net pages you can run Gallio/MB Unit Tests. Those are passed to the Service and the service asks the client(s) to run the tests. It's all working good. What i want to implement now is to update the Asp.net application with the status of the test.
So if the user wants to run a whole assembly of tests at least i should know on the Asp.NET application which test is running and possibly the percentage of the test that is completed.
Any help on how to go about this / what approach to take is greatly appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要定义一个回调合约并在您的 ASP.Net 网站中实现它。您还需要使用 wsDualHttpBinding 添加对双工操作的支持。
该服务通过从OperationContext 获取的代理引用与客户端应用程序进行通信,如以下代码示例所示。
You need to define a callback contract and implement it in your ASP.Net website. You also need to use wsDualHttpBinding to add support for duplex operations.
The service communicates with the client application through a proxy reference that it obtains from OperationContext, as the following code examples show.
SOAP 错误是一种将错误或故障条件从服务传输到使用者的机制。 SOAP 规范包括 SOAP 错误的定义,为发生错误时的消息正文内容提供结构。这使得所有不同的 SOAP 堆栈都可以以标准方式发出错误。
FaultException
用于将非类型化错误数据发送回消费者。FaultException
用于将类型化故障数据发送回客户端的通用版本,其中 TDetail 表示要序列化回消费者的详细故障信息的类型参数作为 SOAP 错误消息的一部分。FaultContractAttribute
FaultContractAttribute 也在 System.ServiceModel 中定义,它使服务开发人员能够声明如果出现问题,给定服务操作可能会出现哪些错误。以下是与使用FaultContractAttribute相关的关键信息:该属性只能应用于操作。
该属性不被继承。
该属性可以多次应用;例如,如果您的服务操作可能返回不同类型的故障,则每种故障类型都会有一个
FaultContractAttribute
声明。该属性的构造函数采用一个 Type 对象,用于引用 Detail 对象的 .NET 类型,即您想要与故障捆绑在一起的故障信息详细信息的类型。
*请注意,您可以定义自己的自定义异常类,而不是本示例中的字符串类。
SOAP fault is a mechanism for transferring error or fault conditions from a service to a consumer. The SOAP specification includes a definition for SOAP faults, providing structure for the contents of the message body when errors occur. This makes it possible for all the different SOAP stacks to issue faults in a standard way.
FaultException
Used to send untyped fault data back to the consumer.FaultException<TDetail>
A generic version used to send typed fault data back to the client, where TDetail represents the type parameter for the detailed fault information to be serialized back to the consumer as part of the SOAP fault message.The
FaultContractAttribute
The FaultContractAttribute, also defined in System.ServiceModel, enables a service developer to declare which faults a given service operation might issue if things go wrong. Following are the key pieces of information pertinent to working with the FaultContractAttribute:The attribute can be applied to operations only.
The attribute is not inherited.
The attribute can be applied multiple times; for instance, if your service operation might return different types of faults, you would have a
FaultContractAttribute
declaration for each type of fault.The attribute’s constructor takes a Type object used to reference the .NET type of the Detail object, that is, the type of fault information details you want to bundle with your faults.
*Please note that instead string class in this example you can define your own custom exception class.