您需要一个[return]
属性来指定如何查找结果。
在 中,SendReplyToReceive
您可以选择发回 aMessage
或Parameters
。根据我的经验,您需要选择Parameters
但只发回一个。假设您将返回参数命名为“result”,那么您需要在接口合同上使用此属性:
[return: MessageParameter(Name = "result")]
这是我的一个完整示例;
namespace NewOrbit.ExVerifier.Model.Workflow.Case
{
using System;
using System.ServiceModel;
using NewOrbit.ExVerifier.Model.Workflow;
[ServiceContract(Namespace = "urn://exverifier.neworbit.co.uk/")]
public interface ICaseWorkflow
{
[OperationContract(Action = "urn://exverifier.neworbit.co.uk/NewOrbit.ExVerifier.Model.Workflow.Case.ICaseWorkflow/Start",
ReplyAction = "urn://exverifier.neworbit.co.uk/NewOrbit.ExVerifier.Model.Workflow.Case.ICaseWorkflow/StartReply")]
[return: MessageParameter(Name = "result")]
WorkflowInstanceIdentifier Start(int caseID);
[OperationContract(Action = "urn://exverifier.neworbit.co.uk/NewOrbit.ExVerifier.Model.Workflow.Case.ICaseWorkflow/ApplicationStateChanged",
ReplyAction = "urn://exverifier.neworbit.co.uk/NewOrbit.ExVerifier.Model.Workflow.Case.ICaseWorkflow/ApplicationStateChangedReply")]
[return: MessageParameter(Name = "result")]
bool ApplicationStateChanged(Guid instanceID, int applicationID);
[OperationContract(Action = "urn://exverifier.neworbit.co.uk/NewOrbit.ExVerifier.Model.Workflow.Case.ICaseWorkflow/Cancel",
ReplyAction = "urn://exverifier.neworbit.co.uk/NewOrbit.ExVerifier.Model.Workflow.Case.ICaseWorkflow/CancelReply")]
[return: MessageParameter(Name = "result")]
bool Cancel(Guid instanceID);
}
}
顺便说一句,在您的示例中,我不确定您如何摆脱不指定 OperationContract 但您很好 - 它们真的很痛苦,因为您必须指定它们的格式在合同和工作流程中是不同的。
此外,以防万一您不知道并且它可能会导致一些非常微妙的错误:您传入的参数是通过名称识别的,因此您在界面中为入站参数指定的名称与您在工作流程。当你想到它时很明显,但可以抓住你。哦,避免方法名称太长,因为它们也会因误导性错误消息而中断。