[英]Implementing WCF callback in MVC
I successfully implemented a WCF service (with wsDualHttpBinding) in MVC. 我在MVC中成功实现了WCF服务(带有wsDualHttpBinding)。
"SendResult" function get correctly called from WCF and receives the results in the "Events_For_Export_Result" array. 从WCF中正确调用了“ SendResult”函数,并在“ Events_For_Export_Result”数组中接收了结果。 Now I should redirect MVC to a controller/view to show a message, but I cannot invoke an action in the call back function.
现在,我应该将MVC重定向到控制器/视图以显示消息,但是我无法在回调函数中调用操作。
As you can see below, I tried to make my callback class inherits from "Controller" and invoked a function that perform a "RedirectToAction", but it does not work. 正如您在下面看到的那样,我试图使回调类继承自“ Controller”并调用执行“ RedirectToAction”的函数,但它不起作用。
What I am doing wrong? 我做错了什么? Is there a way to invoke an action in a void method?
有没有办法在void方法中调用动作?
public class GPWCFServiceCallBackController : Controller, IGPWCFServiceCallback
{
public void SendResult(GPWCFService.Events_For_Export_Result[] arrEvents, string resultMessage)
{
ShowResult(arrEvents, resultMessage);
}
public ActionResult ShowResult(GPWCFService.Events_For_Export_Result[] arrEvents, string resultMessage)
{
return RedirectToAction("Index", "Home");
}
}
I think it has something to do with the nature of the wsDualHttpBinding. 我认为这与wsDualHttpBinding的性质有关。 In fact, I cannot change the return type of the function, since I have to specify [OperationContract(IsOneWay = true)] attribute.
实际上,由于必须指定[OperationContract(IsOneWay = true)]属性,因此我无法更改函数的返回类型。 In this way, the callback function must be void.
这样,回调函数必须为空。
This is the callback interface: 这是回调接口:
/// <summary>
/// The Callback Interface
/// </summary>
public interface IGPWCFServiceCallback
{
[OperationContract(IsOneWay = true)]
void SendResult(Events_For_Export_Result[] arrEvents, string resultMessage);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.