protected void buttonCallBranchProcess_Click(object sender, EventArgs e) { WfServiceAddressDefinition address = new WfServiceAddressDefinition(WfServiceRequestMethod.Post, "http://localhost/MCSWebApp/WfFormTemplate/Services/WfProcessService.svc", WfServiceContentType.Json); WfServiceOperationDefinition definition = new WfServiceOperationDefinition(address, "StartBranchProcesses"); WfServiceOperationParameter p1 = new WfServiceOperationParameter("ownerActivityID", UuidHelper.NewUuidString()); IWfBranchProcessTemplateDescriptor template = new WfBranchProcessTemplateDescriptor("Test"); WfBranchProcessTransferParams transferParams = new WfBranchProcessTransferParams(template); WfServiceOperationParameter p2 = new WfServiceOperationParameter("branchTransferParams", WfSvcOperationParameterType.RuntimeParameter, "transferParams"); definition.Params.Add(p1); definition.Params.Add(p2); WfServiceInvoker invoker = new WfServiceInvoker(definition); WfServiceInvoker.InvokeContext["transferParams"] = transferParams; object result = invoker.Invoke(); resultLabel.Text = Server.HtmlEncode(result.ToString()); }
protected void Page_Load(object sender, EventArgs e) { WfConverterHelper.RegisterConverters(); WfServiceOperationDefinition svcOpDef = new WfServiceOperationDefinition(); hiddenSvcOperationTemplate.Value = JSONSerializerExecute.Serialize(svcOpDef); var dataTypeList = EnumItemDescriptionAttribute.GetDescriptionList(typeof(WfSvcOperationParameterType)); dataTypeDropDownList.DataSource = dataTypeList; dataTypeDropDownList.DataTextField = "Name"; dataTypeDropDownList.DataValueField = "EnumValue"; dataTypeDropDownList.DataBind(); if (Request["hasRtn"] == "false") { this.trRtn.Style["display"] = "none"; } if (!string.IsNullOrEmpty(Request["initPara"])) { var initData = new WfServiceOperationParameterCollection(); initData.Add(new WfServiceOperationParameter() { Name = Request["initPara"], Type = WfSvcOperationParameterType.RuntimeParameter, Value = "" }); detailGrid.InitialData = initData; } }
private static JobBase CreateInvokeServiceJob() { InvokeWebServiceJob job = new InvokeWebServiceJob(); job.JobID = UuidHelper.NewUuidString(); job.Name = "即时服务调用"; job.SvcOperationDefs = new WfServiceOperationDefinitionCollection(); job.LastStartExecuteTime = DateTime.Now.AddMinutes(-5); job.Category = "单元测试"; WfServiceAddressDefinition address = new WfServiceAddressDefinition(WfServiceRequestMethod.Post, null, "http://localhost/MCSWebApp/PermissionCenterServices/Services/PermissionCenterToADService.asmx"); WfServiceOperationParameterCollection parameters = new WfServiceOperationParameterCollection(); parameters.Add(new WfServiceOperationParameter() { Name = "callerID", Type = WfSvcOperationParameterType.RuntimeParameter, Value = "callerID" }); WfServiceOperationDefinition serviceDef = new WfServiceOperationDefinition(address, "GetVersion", parameters, string.Empty); serviceDef.RtnXmlStoreParamName = "Version"; serviceDef.Timeout = TimeSpan.FromSeconds(30); job.SvcOperationDefs.Add(serviceDef); return(job); }
public WfServiceInvoker(WfServiceOperationDefinition svcOperationDef) { this._SvcOperationDef = svcOperationDef; this.InitConnectionMappings(); this.InitHeaders(); }
protected void buttonCallBranchProcess_Click(object sender, EventArgs e) { WfServiceAddressDefinition address = new WfServiceAddressDefinition(WfServiceRequestMethod.Post, "http://localhost/MCSWebApp/WfFormTemplate/Services/WfProcessService.svc", WfServiceContentType.Json); WfServiceOperationDefinition definition = new WfServiceOperationDefinition(address, "StartBranchProcesses"); WfServiceOperationParameter p1 = new WfServiceOperationParameter("ownerActivityID", UuidHelper.NewUuidString()); IWfBranchProcessTemplateDescriptor template = new WfBranchProcessTemplateDescriptor("Test"); WfBranchProcessTransferParams transferParams = new WfBranchProcessTransferParams(template); WfServiceOperationParameter p2 = new WfServiceOperationParameter("branchTransferParams", WfSvcOperationParameterType.RuntimeParameter, "transferParams"); definition.Params.Add(p1); definition.Params.Add(p2); WfServiceInvoker invoker = new WfServiceInvoker(definition); WfServiceInvoker.InvokeContext["transferParams"] = transferParams; object result = invoker.Invoke(); resultLabel.Text = Server.HtmlEncode(result.ToString()); }
public WfServiceOperationDefinition AddCompensationService <TChannel>(string url, Action <TChannel> action) { url.CheckStringIsNullOrEmpty("url"); return(this.CompensationServices.Append(WfServiceOperationDefinition.CreateFromAction(action). SetAddress(WfServiceRequestMethod.Post, url, WfServiceContentType.Json))); }
private WfServiceOperationDefinition GetWfServiceOperationDefinition(string functionName, string servicAddressKey) { WfServiceAddressDefinition serviceAddressDef = WfGlobalParameters.Default.ServiceAddressDefs[servicAddressKey]; string addressUri = GetWsdlUrl(serviceAddressDef.Address); WebClient wc = new WebClient(); using (Stream stream = wc.OpenRead(addressUri)) { ServiceDescription sd = ServiceDescription.Read(stream); Binding targetBinding = GetBinding(sd, serviceAddressDef.RequestMethod); if (targetBinding == null && serviceAddressDef.RequestMethod == WfServiceRequestMethod.Post) { targetBinding = GetPostableBinding(sd); } if (targetBinding == null) { throw new NotImplementedException("服务不支持此种操作类型" + serviceAddressDef.RequestMethod.ToString()); } Operation operation = GetOperation(sd, targetBinding, functionName); WfServiceOperationParameterCollection reqParameters = GetOperationParams(sd, operation); WfServiceOperationDefinition operationDef = new WfServiceOperationDefinition(serviceAddressDef.Key, functionName, reqParameters, string.Empty); return(operationDef); } }
protected void Page_Load(object sender, EventArgs e) { WfConverterHelper.RegisterConverters(); WfServiceOperationDefinition svcOpDef = new WfServiceOperationDefinition(); hiddenSvcOperationTemplate.Value = JSONSerializerExecute.Serialize(svcOpDef); var dataTypeList = EnumItemDescriptionAttribute.GetDescriptionList(typeof(WfSvcOperationParameterType)); dataTypeDropDownList.DataSource = dataTypeList; dataTypeDropDownList.DataTextField = "Name"; dataTypeDropDownList.DataValueField = "EnumValue"; dataTypeDropDownList.DataBind(); if (Request["hasRtn"] == "false") { this.trRtn.Style["display"] = "none"; } if (!string.IsNullOrEmpty(Request["initPara"])) { var initData = new WfServiceOperationParameterCollection(); initData.Add(new WfServiceOperationParameter() { Name = Request["initPara"], Type = WfSvcOperationParameterType.RuntimeParameter, Value = "" }); detailGrid.InitialData = initData; } }
public void WcfServiceTest() { WfNetworkCredential credential = new WfNetworkCredential(); string url = @"http://localhost/MCSWebApp/WcfServiceDemo/Service1.svc"; string addressKey = "testaddress"; WfServiceAddressDefinition addressDef = new WfServiceAddressDefinition(WfServiceRequestMethod.Post, credential, url); addressDef.Key = addressKey; addressDef.ContentType = WfServiceContentType.Json; WfGlobalParameters.Default.ServiceAddressDefs.Add(addressDef); string paraVal = @"{""BoolValue"":""true"",""StringValue"":""test""}"; WfServiceOperationParameter operationParam = new WfServiceOperationParameter() { Name = "composite", Type = WfSvcOperationParameterType.String, Value = paraVal }; WfServiceOperationDefinition operationDef = new WfServiceOperationDefinition(addressKey, "PostContract", new WfServiceOperationParameterCollection() { operationParam }, ""); WfServiceInvoker invoker = new WfServiceInvoker(operationDef); var result = invoker.Invoke(); Console.WriteLine(result.ToString()); }
public WfServiceInvoker(WfServiceOperationDefinition svcOperationDef, WfApplicationRuntimeParameters invokeContext) { this._SvcOperationDef = svcOperationDef; this._InvokeContext = invokeContext; this.InitConnectionMappings(); this.InitHeaders(); }
public static void AreEqual(this WfServiceOperationDefinition actual, WfServiceOperationDefinitionConfigurationElement element) { AssertStringEqual(actual.OperationName, element.OperationName); AssertStringEqual(actual.RtnXmlStoreParamName, element.ReturnParamName); AssertStringEqual(actual.AddressDef.Key, element.AddressKey); Assert.AreEqual(actual.InvokeWhenPersist, element.InvokeWhenPersist); actual.Params.AreEqual(element.Parameters); }
public void ServiceDefinitionSettingsTest() { WfServiceOperationDefinitionConfigurationElement operationElement = WfServiceDefinitionSettings.GetSection().Operations["PCGetVersion"]; Assert.IsNotNull(operationElement); WfServiceOperationDefinition operation = new WfServiceOperationDefinition(operationElement); operation.AreEqual(operationElement); }
public void ServiceDefinitionSettingsTest() { WfServiceOperationDefinitionConfigurationElement operationElement = WfServiceDefinitionSettings.GetSection().Operations["PCGetVersion"]; Assert.IsNotNull(operationElement); WfServiceOperationDefinition operation = new WfServiceOperationDefinition(operationElement); operation.AreEqual(operationElement); }
public WfServiceInvokerFactory() { Url = @"http://localhost/MCSWebApp/WebTestProject/Services/ProcessTestService.asmx"; ParaList = new WfServiceOperationParameterCollection(); Credential = new WfNetworkCredential(); AddressDef = new WfServiceAddressDefinition(WfServiceRequestMethod.Get, Credential, Url); AddressDef.Key = Guid.NewGuid().ToString(); WfGlobalParameters.Default.ServiceAddressDefs.Add(AddressDef); AddressDef.ServiceNS = @"http://tempuri.org/"; SvcOpDef = new WfServiceOperationDefinition(AddressDef.Key, Operation, ParaList, ""); }
public WfServiceInvokerFactory() { Url = @"http://localhost/MCSWebApp/WebTestProject/Services/ProcessTestService.asmx"; ParaList = new WfServiceOperationParameterCollection(); Credential = new WfNetworkCredential(); AddressDef = new WfServiceAddressDefinition(WfServiceRequestMethod.Get, Credential, Url); AddressDef.Key = Guid.NewGuid().ToString(); WfGlobalParameters.Default.ServiceAddressDefs.Add(AddressDef); AddressDef.ServiceNS = @"http://tempuri.org/"; SvcOpDef = new WfServiceOperationDefinition(AddressDef.Key, Operation, ParaList, ""); }
public string getAnalysisResult(string functionName, string servicAddress) { WfServiceOperationDefinition state = GetWfServiceOperationDefinition(functionName, servicAddress); if (state != null) { return(JSONSerializerExecute.Serialize(state, state.GetType())); } else { return(""); } }
protected virtual void InitServiceDefinitions() { WfServiceAddressDefinition address = new WfServiceAddressDefinition(WfServiceRequestMethod.Post, string.Empty, WfServiceContentType.Json); this.PrepareAddress(address); WfServiceOperationParameterCollection parameters = new WfServiceOperationParameterCollection(); WfServiceOperationDefinition definition = new WfServiceOperationDefinition(address, this.GetOperationName(), parameters, "returnValue"); this.PrepareParameters(parameters); this.SvcOperationDefs.Add(definition); }
protected void buttonGetServiceName_Click(object sender, EventArgs e) { WfServiceAddressDefinition address = new WfServiceAddressDefinition(WfServiceRequestMethod.Post, "http://localhost/MCSWebApp/WfFormTemplate/Services/WfProcessService.svc", WfServiceContentType.Json); WfServiceOperationDefinition definition = new WfServiceOperationDefinition(address, "GetServerTime"); WfServiceInvoker invoker = new WfServiceInvoker(definition); object result = invoker.Invoke(); resultLabel.Text = Server.HtmlEncode(result.ToString()); }
protected void buttonGetServiceName_Click(object sender, EventArgs e) { WfServiceAddressDefinition address = new WfServiceAddressDefinition(WfServiceRequestMethod.Post, "http://localhost/MCSWebApp/WfFormTemplate/Services/WfProcessService.svc", WfServiceContentType.Json); WfServiceOperationDefinition definition = new WfServiceOperationDefinition(address, "GetServerTime"); WfServiceInvoker invoker = new WfServiceInvoker(definition); object result = invoker.Invoke(); resultLabel.Text = Server.HtmlEncode(result.ToString()); }
protected virtual void InitServiceDefinitions() { WfServiceAddressDefinition address = new WfServiceAddressDefinition(WfServiceRequestMethod.Post, string.Empty, WfServiceContentType.Json); this.PrepareAddress(address); WfServiceOperationParameterCollection parameters = new WfServiceOperationParameterCollection(); WfServiceOperationDefinition definition = new WfServiceOperationDefinition(address, this.GetOperationName(), parameters, "returnValue"); this.PrepareParameters(parameters); this.SvcOperationDefs.Add(definition); }
internal static InvokeWebServiceJob CreateImmediateJob(string jobID, string name, string category, string url, string methodName, WfServiceOperationParameterCollection parameters) { InvokeWebServiceJob job = new InvokeWebServiceJob(); job.JobID = jobID; job.Category = category; job.Name = name; job.SvcOperationDefs = new WfServiceOperationDefinitionCollection(); WfServiceAddressDefinition address = new WfServiceAddressDefinition(WfServiceRequestMethod.Post, null, url); WfServiceOperationDefinition serviceDef = new WfServiceOperationDefinition(address, methodName, parameters, string.Empty); serviceDef.Timeout = TimeSpan.FromSeconds(24 * 60 * 60); job.SvcOperationDefs.Add(serviceDef); return(job); }
/// <summary> /// 将服务定义加入流程每个节点上 /// </summary> /// <param name="enter"></param> /// <param name="leave"></param> /// <returns></returns> public static IWfProcess StartupProcessWithServiceDefinition(WfServiceOperationDefinition enter, WfServiceOperationDefinition leave) { ProcessContextAction(); IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateProcessDescriptor(); foreach (var item in processDesp.Activities) { item.EnterEventExecuteServices.Add(enter); item.LeaveEventExecuteServices.Add(leave); } processDesp.InitialActivity.Resources.Add(new WfUserResourceDescriptor((IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object)); WfProcessStartupParams startupParams = GetInstanceOfWfProcessStartupParams(processDesp); return(WfRuntime.StartWorkflow(startupParams)); }
public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer) { WfServiceOperationDefinition svcOperationDef = new WfServiceOperationDefinition(); svcOperationDef.Key = DictionaryHelper.GetValue(dictionary, "Key", string.Empty); svcOperationDef.OperationName = DictionaryHelper.GetValue(dictionary, "OperationName", string.Empty); svcOperationDef.InvokeWhenPersist = DictionaryHelper.GetValue(dictionary, "InvokeWhenPersist", false); if (dictionary.ContainsKey("Timeout")) { string strTimeout = DictionaryHelper.GetValue(dictionary, "Timeout", string.Empty); if (strTimeout.IsNotEmpty()) { string[] parts = strTimeout.Split('T'); if (parts.Length > 1) strTimeout = parts[1]; TimeSpan timeoutSpan = TimeSpan.Parse(strTimeout); svcOperationDef.Timeout = timeoutSpan; } } svcOperationDef.RtnXmlStoreParamName = DictionaryHelper.GetValue(dictionary, "RtnXmlStoreParamName", string.Empty); if (dictionary.ContainsKey("AddressDef")) { var addressDef = JSONSerializerExecute.Deserialize<WfServiceAddressDefinition>(dictionary["AddressDef"]); svcOperationDef.AddressDef = addressDef; } if (dictionary.ContainsKey("Params")) { var templates = JSONSerializerExecute.Deserialize<WfServiceOperationParameterCollection>(dictionary["Params"]); svcOperationDef.Params.Clear(); svcOperationDef.Params.CopyFrom(templates); } return svcOperationDef; }
public void CallServiceTest() { WfServiceOperationDefinitionConfigurationElement operationElement = WfServiceDefinitionSettings.GetSection().Operations["PCGetVersion"]; Assert.IsNotNull(operationElement); WfServiceOperationDefinition operation = new WfServiceOperationDefinition(operationElement); WfServiceInvoker.InvokeContext["Version"] = string.Empty; WfServiceInvoker.InvokeContext["callerID"] = "Zheng Shen"; WfServiceInvoker invoker = new WfServiceInvoker(operation); invoker.Invoke(); string result = WfServiceInvoker.InvokeContext.GetValue("Version", string.Empty); Console.WriteLine(result); Assert.IsTrue(result.IndexOf(WfServiceInvoker.InvokeContext.GetValue("callerID", string.Empty)) >= 0); }
public void CallServiceTest() { WfServiceOperationDefinitionConfigurationElement operationElement = WfServiceDefinitionSettings.GetSection().Operations["PCGetVersion"]; Assert.IsNotNull(operationElement); WfServiceOperationDefinition operation = new WfServiceOperationDefinition(operationElement); WfServiceInvoker.InvokeContext["Version"] = string.Empty; WfServiceInvoker.InvokeContext["callerID"] = "Zheng Shen"; WfServiceInvoker invoker = new WfServiceInvoker(operation); invoker.Invoke(); string result = WfServiceInvoker.InvokeContext.GetValue("Version", string.Empty); Console.WriteLine(result); Assert.IsTrue(result.IndexOf(WfServiceInvoker.InvokeContext.GetValue("callerID", string.Empty)) >= 0); }
private static JobBase CreateInvokeServiceJob() { InvokeWebServiceJob job = new InvokeWebServiceJob(); job.JobID = UuidHelper.NewUuidString(); job.Name = "即时服务调用"; job.SvcOperationDefs = new WfServiceOperationDefinitionCollection(); job.LastStartExecuteTime = DateTime.Now.AddMinutes(-5); job.Category = "单元测试"; WfServiceAddressDefinition address = new WfServiceAddressDefinition(WfServiceRequestMethod.Post, null, "http://localhost/MCSWebApp/PermissionCenterServices/Services/PermissionCenterToADService.asmx"); WfServiceOperationParameterCollection parameters = new WfServiceOperationParameterCollection(); parameters.Add(new WfServiceOperationParameter() { Name = "callerID", Type = WfSvcOperationParameterType.RuntimeParameter, Value = "callerID" }); WfServiceOperationDefinition serviceDef = new WfServiceOperationDefinition(address, "GetVersion", parameters, string.Empty); serviceDef.RtnXmlStoreParamName = "Version"; serviceDef.Timeout = TimeSpan.FromSeconds(30); job.SvcOperationDefs.Add(serviceDef); return job; }
internal static InvokeWebServiceJob CreateImmediateJob(string jobID, string name, string category, string url, string methodName, WfServiceOperationParameterCollection parameters) { InvokeWebServiceJob job = new InvokeWebServiceJob(); job.JobID = jobID; job.Category = category; job.Name = name; job.SvcOperationDefs = new WfServiceOperationDefinitionCollection(); WfServiceAddressDefinition address = new WfServiceAddressDefinition(WfServiceRequestMethod.Post, null, url); WfServiceOperationDefinition serviceDef = new WfServiceOperationDefinition(address, methodName, parameters, string.Empty); serviceDef.Timeout = TimeSpan.FromSeconds(24 * 60 * 60); job.SvcOperationDefs.Add(serviceDef); return job; }
public void Setup() { SvcOpDef = new WfServiceInvokerFactory().SvcOpDef; }
public void WcfServiceTest() { WfNetworkCredential credential = new WfNetworkCredential(); string url = @"http://localhost/MCSWebApp/WcfServiceDemo/Service1.svc"; string addressKey = "testaddress"; WfServiceAddressDefinition addressDef = new WfServiceAddressDefinition(WfServiceRequestMethod.Post, credential, url); addressDef.Key = addressKey; addressDef.ContentType = WfServiceContentType.Json; WfGlobalParameters.Default.ServiceAddressDefs.Add(addressDef); string paraVal = @"{""BoolValue"":""true"",""StringValue"":""test""}"; WfServiceOperationParameter operationParam = new WfServiceOperationParameter() { Name = "composite", Type = WfSvcOperationParameterType.String, Value = paraVal }; WfServiceOperationDefinition operationDef = new WfServiceOperationDefinition(addressKey, "PostContract", new WfServiceOperationParameterCollection() { operationParam }, ""); WfServiceInvoker invoker = new WfServiceInvoker(operationDef); var result = invoker.Invoke(); Console.WriteLine(result.ToString()); }
public void Setup() { SvcOpDef = new WfServiceInvokerFactory().SvcOpDef; }
/// <summary> /// 将服务定义加入流程每个节点上 /// </summary> /// <param name="enter"></param> /// <param name="leave"></param> /// <returns></returns> public static IWfProcess StartupProcessWithServiceDefinition(WfServiceOperationDefinition enter, WfServiceOperationDefinition leave) { ProcessContextAction(); IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateProcessDescriptor(); foreach (var item in processDesp.Activities) { item.EnterEventExecuteServices.Add(enter); item.LeaveEventExecuteServices.Add(leave); } processDesp.InitialActivity.Resources.Add(new WfUserResourceDescriptor((IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object)); WfProcessStartupParams startupParams = GetInstanceOfWfProcessStartupParams(processDesp); return WfRuntime.StartWorkflow(startupParams); }