private static bool ProcessEventParameters(WorkflowParameterBindingCollection parameters, IMethodMessage message, Type interfaceType, string operation) { bool isKnownSignature = false; if (parameters == null) { return(isKnownSignature); } EventInfo eventInfo = interfaceType.GetEvent(operation); MethodInfo methodInfo = eventInfo.EventHandlerType.GetMethod("Invoke"); int index = 0; foreach (ParameterInfo formalParameter in methodInfo.GetParameters()) { if ((typeof(ExternalDataEventArgs).IsAssignableFrom(formalParameter.ParameterType))) { if (index == 1) { isKnownSignature = true; } } if (parameters.Contains(formalParameter.Name)) { WorkflowParameterBinding binding = parameters[formalParameter.Name]; binding.Value = message.Args[index]; } index++; } return(isKnownSignature); }
void Container4() { //ReceiveActivity.ServiceOperationInfo //<snippet4> ReceiveActivity receiveQuoteFromShipper1 = new ReceiveActivity(); CodeActivity shipper1ShippingQuote = new CodeActivity(); ContextToken contextToken1 = new ContextToken(); ActivityBind activityBind1 = new ActivityBind(); WorkflowParameterBinding workflowParameterBinding1 = new WorkflowParameterBinding(); TypedOperationInfo typedOperationInfo1 = new TypedOperationInfo(); receiveQuoteFromShipper1.Activities.Add(shipper1ShippingQuote); contextToken1.Name = "Shipper1Context"; contextToken1.OwnerActivityName = "GetShippingQuotes"; receiveQuoteFromShipper1.ContextToken = contextToken1; receiveQuoteFromShipper1.Name = "receiveQuoteFromShipper1"; activityBind1.Name = "SupplierWorkflow"; activityBind1.Path = "quoteShipper1"; workflowParameterBinding1.ParameterName = "quote"; workflowParameterBinding1.SetBinding(WorkflowParameterBinding.ValueProperty, ((ActivityBind)(activityBind1))); receiveQuoteFromShipper1.ParameterBindings.Add(workflowParameterBinding1); typedOperationInfo1.ContractType = typeof(IShippingQuote); typedOperationInfo1.Name = "ShippingQuote"; receiveQuoteFromShipper1.ServiceOperationInfo = typedOperationInfo1; //</snippet4> }
public void TestConstructorNullException() { WorkflowParameterBindingCollection wc = new WorkflowParameterBindingCollection(new ParallelActivity()); WorkflowParameterBinding pb1 = new WorkflowParameterBinding(); wc.Add(pb1); }
void Container0() { ChannelToken channelToken1 = new ChannelToken(); SendActivity RequestQuoteFromShipper3 = new SendActivity(); ActivityBind activityBind2 = new ActivityBind(); ActivityBind activityBind3 = new ActivityBind(); ActivityBind activityBind4 = new ActivityBind(); WorkflowParameterBinding workflowParameterBinding2 = new WorkflowParameterBinding(); WorkflowParameterBinding workflowParameterBinding3 = new WorkflowParameterBinding(); WorkflowParameterBinding workflowParameterBinding4 = new WorkflowParameterBinding(); //SendActivity.ParameterBindings //<snippet0> channelToken1.EndpointName = "Shipper3Endpoint"; channelToken1.Name = "Shipper3Endpoint"; channelToken1.OwnerActivityName = "GetShippingQuotes"; RequestQuoteFromShipper3.ChannelToken = channelToken1; RequestQuoteFromShipper3.Name = "RequestQuoteFromShipper3"; activityBind2.Name = "SupplierWorkflow"; activityBind2.Path = "order"; workflowParameterBinding2.ParameterName = "po"; workflowParameterBinding2.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, ((System.Workflow.ComponentModel.ActivityBind)(activityBind2))); activityBind3.Name = "SupplierWorkflow"; activityBind3.Path = "contextShipper3"; workflowParameterBinding3.ParameterName = "context"; workflowParameterBinding3.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, ((System.Workflow.ComponentModel.ActivityBind)(activityBind3))); activityBind4.Name = "SupplierWorkflow"; activityBind4.Path = "ackShipper3"; workflowParameterBinding4.ParameterName = "(ReturnValue)"; workflowParameterBinding4.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, ((System.Workflow.ComponentModel.ActivityBind)(activityBind4))); RequestQuoteFromShipper3.ParameterBindings.Add(workflowParameterBinding2); RequestQuoteFromShipper3.ParameterBindings.Add(workflowParameterBinding3); RequestQuoteFromShipper3.ParameterBindings.Add(workflowParameterBinding4); //</snippet0> }
public override void SetValue(object component, object value) { if (component != null) { IServiceProvider site = MemberDescriptor.GetSite(component); ComponentChangeDispatcher dispatcher = (site != null) ? new ComponentChangeDispatcher(site, component, this) : null; try { WorkflowParameterBindingCollection parameterBindings = this.GetParameterBindings(component); if (parameterBindings != null) { string key = string.Empty; if (this.Name.StartsWith("(Parameter) ", StringComparison.Ordinal)) { key = this.Name.Substring("(Parameter) ".Length); } else { key = this.Name; } WorkflowParameterBinding item = null; if (parameterBindings.Contains(key)) { item = parameterBindings[key]; } else { item = new WorkflowParameterBinding(key); parameterBindings.Add(item); } if (value is ActivityBind) { item.SetBinding(WorkflowParameterBinding.ValueProperty, value as ActivityBind); } else { item.SetValue(WorkflowParameterBinding.ValueProperty, value); } this.OnValueChanged(component, EventArgs.Empty); } } catch (Exception exception) { if ((exception is TargetInvocationException) && (exception.InnerException != null)) { throw exception.InnerException; } throw exception; } finally { if (dispatcher != null) { dispatcher.Dispose(); } } } }
protected override ActivityExecutionStatus Execute(ActivityExecutionContext aec) { // intercept before the call base.RaiseEvent(AdapterActivity.InvokingEvent, this, EventArgs.Empty); OnMethodInvoking(EventArgs.Empty); #region Invoke remoting object MethodInfo mi = Type.GetMethod(this.MethodName, BindingFlags.Public | BindingFlags.Instance); object[] objArray = Helpers.GetParameters(mi, this.Parameters); WorkflowParameterBinding returnValueBinding = null; if (this.Parameters.Contains("(ReturnValue)")) { returnValueBinding = this.Parameters["(ReturnValue)"]; } try { // endpoint string objectUri = this.Uri.StartsWith("@") ? ConfigurationManager.AppSettings[this.Uri.Substring(1)] : this.Uri; if (string.IsNullOrEmpty(objectUri)) { throw new Exception(string.Format("Missing endpoint in {0}", this.QualifiedName)); } object proxy = Activator.GetObject(this.Type, objectUri); object retVal = Type.InvokeMember(this.MethodName, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, proxy, objArray, CultureInfo.InvariantCulture); if (returnValueBinding != null) { returnValueBinding.Value = retVal; } } catch (TargetInvocationException ex) { if (ex.InnerException != null) { throw ex.InnerException; } Trace.WriteLine(ex); throw; } catch (Exception ex) { Trace.WriteLine(ex); throw; } Helpers.SaveOutRefParameters(objArray, mi, this.Parameters); #endregion // intercept after the call base.RaiseEvent(AdapterActivity.InvokedEvent, this, EventArgs.Empty); OnMethodInvoked(EventArgs.Empty); // activity is done return(ActivityExecutionStatus.Closed); }
protected virtual void ProcessQueueItem(ActivityExecutionContext executionContext, object item) { IMethodCallMessage message = item as IMethodCallMessage; if (message == null) { Exception exception = message as Exception; if (exception != null) { throw exception; } throw new InvalidOperationException("Invalid LocalServiceMessage"); } else if (message.MethodName == this.MethodName) { // LogicalCallConetext LCC.CopyFrom(message); // roles Helpers.ValidateRoles(this, message); WorkflowParameterBindingCollection collection = this.Parameters; if (collection != null) { int ii = 0; MethodInfo mi = this.Type.GetMethod(this.MethodName); if (mi != null) { foreach (ParameterInfo pi in mi.GetParameters()) { if (!pi.ParameterType.IsByRef && (!pi.IsIn || !pi.IsOut)) { if (collection.Contains(pi.Name)) { WorkflowParameterBinding binding = collection[pi.Name]; binding.Value = message.InArgs[ii++]; } } } } } // postprocessing OnReceived(EventArgs.Empty); base.RaiseEvent(OperationContractWorkflowBase.ReceivedEvent, this, EventArgs.Empty); // done return; } throw new InvalidOperationException("Invalid received MethodMessage"); }
private void ProcessParameters(ActivityExecutionContext context, IMethodMessage message, Type interfaceType, string operation) { WorkflowParameterBindingCollection parameters = ParameterBindings; if (parameters == null) { return; } //cache mInfo todo MethodInfo mInfo = interfaceType.GetMethod(operation); if (mInfo == null) { return; } int index = 0; bool responseRequired = false; foreach (ParameterInfo formalParameter in mInfo.GetParameters()) { // populate in params, checking on IsIn alone is not sufficient if (!(formalParameter.ParameterType.IsByRef || (formalParameter.IsIn && formalParameter.IsOut))) { if (parameters.Contains(formalParameter.Name)) { WorkflowParameterBinding binding = parameters[formalParameter.Name]; binding.Value = message.Args[index++]; } } else { responseRequired = true; } } if (mInfo.ReturnType != typeof(void) || responseRequired) { // create queue entry {interface, operation and receive activity Id} IComparable queueId = new EventQueueName(interfaceType, operation, QualifiedName); // enqueue the message for sendresponse reply context WorkflowQueuingService queuingService = (WorkflowQueuingService)context.GetService(typeof(WorkflowQueuingService)); if (!queuingService.Exists(queueId)) { queuingService.CreateWorkflowQueue(queueId, true); } queuingService.GetWorkflowQueue(queueId).Enqueue(message); } }
protected sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { if (executionContext == null) { throw new ArgumentNullException("executionContext"); } if (this.InterfaceType == null) { throw new ArgumentException( SR.GetString(SR.Error_MissingInterfaceType), "executionContext"); } Type type = this.InterfaceType; string methodName = this.MethodName; object serviceValue = executionContext.GetService(type); if (serviceValue == null) { throw new InvalidOperationException(SR.GetString(SR.Error_ServiceNotFound, this.InterfaceType)); } this.RaiseEvent(MethodInvokingEvent, this, EventArgs.Empty); OnMethodInvoking(EventArgs.Empty); MethodInfo methodInfo = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public); ParameterModifier[] parameterModifiers = null; object[] actualParameters = InvokeHelper.GetParameters(methodInfo, this.ParameterBindings, out parameterModifiers); WorkflowParameterBinding resultBinding = null; if (this.ParameterBindings.Contains("(ReturnValue)")) { resultBinding = this.ParameterBindings["(ReturnValue)"]; } CorrelationService.InvalidateCorrelationToken(this, type, methodName, actualParameters); object result = type.InvokeMember(this.MethodName, BindingFlags.InvokeMethod, new ExternalDataExchangeBinder(), serviceValue, actualParameters, parameterModifiers, null, null); if (resultBinding != null) { resultBinding.Value = InvokeHelper.CloneOutboundValue(result, new BinaryFormatter(), "(ReturnValue)"); } InvokeHelper.SaveOutRefParameters(actualParameters, methodInfo, this.ParameterBindings); OnMethodInvoked(EventArgs.Empty); return(ActivityExecutionStatus.Closed); }
public void Constructor1() { WorkflowParameterBinding wmp = new WorkflowParameterBinding(); // Default values Assert.AreEqual(null, wmp.ParameterName, "C1#1"); Assert.AreEqual(null, wmp.Value, "C1#2"); // Accesors setters wmp.ParameterName = "Hola"; wmp.Value = wmp; Assert.AreEqual("Hola", wmp.ParameterName, "C1#1"); Assert.AreEqual(wmp, wmp.Value, "C1#2"); }
internal static object[] GetParameters(MethodBase methodBase, WorkflowParameterBindingCollection parameterBindings) { ParameterInfo[] parameters = methodBase.GetParameters(); object[] objArray = new object[parameters.Length]; int index = 0; foreach (ParameterInfo info in parameters) { if (parameterBindings.Contains(info.Name)) { WorkflowParameterBinding binding = parameterBindings[info.Name]; objArray[index] = binding.Value; } index++; } return(objArray); }
public void TestAddRemove() { WorkflowParameterBindingCollection wc = new WorkflowParameterBindingCollection(new ParallelActivity()); WorkflowParameterBinding pb1 = new WorkflowParameterBinding("Name1"); WorkflowParameterBinding pb2 = new WorkflowParameterBinding("Name2"); WorkflowParameterBinding pb3 = new WorkflowParameterBinding("Name3"); wc.Add(pb1); wc.Add(pb2); wc.Add(pb3); Assert.AreEqual(3, wc.Count, "C1#1"); Assert.AreEqual(pb1, wc[0], "C1#2"); Assert.AreEqual(pb2, wc[1], "C1#3"); Assert.AreEqual(pb3, wc[2], "C1#4"); }
public static object[] GetParameters(MethodBase methodBase, WorkflowParameterBindingCollection parameterBindings) { ParameterInfo[] infoArray = methodBase.GetParameters(); object[] objArray = new object[infoArray.Length]; int ii = 0; foreach (ParameterInfo pi in infoArray) { if (parameterBindings.Contains(pi.Name)) { WorkflowParameterBinding binding = parameterBindings[pi.Name]; objArray[ii] = binding.Value; } ii++; } return(objArray); }
internal static object[] GetParameters(MethodBase methodBase, WorkflowParameterBindingCollection parameterBindings) { ParameterInfo[] formalParameters = methodBase.GetParameters(); object[] actualParameters = new object[formalParameters.Length]; int index = 0; foreach (ParameterInfo formalParameter in formalParameters) { if (parameterBindings.Contains(formalParameter.Name)) { WorkflowParameterBinding binding = parameterBindings[formalParameter.Name]; actualParameters[index] = binding.Value; } index++; } return(actualParameters); }
protected sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { if (executionContext == null) { throw new ArgumentNullException("executionContext"); } if ((this.SessionId != "") && (this.SessionId != null)) { this.PopulateSessionCookie(); } object proxyInstance = Activator.CreateInstance(this.ProxyClass); HttpWebClientProtocol protocol = proxyInstance as HttpWebClientProtocol; protocol.CookieContainer = this.SessionCookieContainer; base.RaiseGenericEvent <InvokeWebServiceEventArgs>(InvokingEvent, this, new InvokeWebServiceEventArgs(proxyInstance)); MethodInfo method = this.ProxyClass.GetMethod(this.MethodName, BindingFlags.Public | BindingFlags.Instance); object[] parameters = InvokeHelper.GetParameters(method, this.ParameterBindings); WorkflowParameterBinding binding = null; if (this.ParameterBindings.Contains("(ReturnValue)")) { binding = this.ParameterBindings["(ReturnValue)"]; } object obj3 = null; try { obj3 = this.ProxyClass.InvokeMember(this.MethodName, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, proxyInstance, parameters, CultureInfo.InvariantCulture); } catch (TargetInvocationException exception) { if (exception.InnerException != null) { throw exception.InnerException; } throw; } if (binding != null) { binding.Value = obj3; } InvokeHelper.SaveOutRefParameters(parameters, method, this.ParameterBindings); base.RaiseGenericEvent <InvokeWebServiceEventArgs>(InvokedEvent, this, new InvokeWebServiceEventArgs(proxyInstance)); return(ActivityExecutionStatus.Closed); }
public static void SaveOutRefParameters(object[] actualParameters, MethodBase methodBase, WorkflowParameterBindingCollection parameterBindings) { int ii = 0; BinaryFormatter bf = null; foreach (ParameterInfo pi in methodBase.GetParameters()) { if (parameterBindings.Contains(pi.Name) && (pi.ParameterType.IsByRef || (pi.IsIn && pi.IsOut))) { WorkflowParameterBinding binding = parameterBindings[pi.Name]; if (bf == null) { bf = new BinaryFormatter(); } binding.Value = CloneOutboundValue(actualParameters[ii], bf, pi.Name); } ii++; } }
internal static void SaveOutRefParameters(object[] actualParameters, MethodBase methodBase, WorkflowParameterBindingCollection parameterBindings) { int index = 0; BinaryFormatter formatter = null; foreach (ParameterInfo info in methodBase.GetParameters()) { if (parameterBindings.Contains(info.Name) && (info.ParameterType.IsByRef || (info.IsIn && info.IsOut))) { WorkflowParameterBinding binding = parameterBindings[info.Name]; if (formatter == null) { formatter = new BinaryFormatter(); } binding.Value = CloneOutboundValue(actualParameters[index], formatter, info.Name); } index++; } }
internal static object[] GetParameters(MethodBase methodBase, WorkflowParameterBindingCollection parameterBindings, out ParameterModifier[] parameterModifiers) { ParameterInfo[] formalParameters = methodBase.GetParameters(); object[] actualParameters = new object[formalParameters.Length]; if (actualParameters.Length == 0) { parameterModifiers = new ParameterModifier[0]; return(actualParameters); } int index = 0; BinaryFormatter formatter = null; ParameterModifier parameterModifier = new ParameterModifier(actualParameters.Length); foreach (ParameterInfo formalParameter in formalParameters) { if (formalParameter.ParameterType.IsByRef) { parameterModifier[index] = true; } else { parameterModifier[index] = false; } if (parameterBindings.Contains(formalParameter.Name)) { WorkflowParameterBinding binding = parameterBindings[formalParameter.Name]; if (formatter == null) { formatter = new BinaryFormatter(); } actualParameters[index] = CloneOutboundValue(binding.Value, formatter, formalParameter.Name); } index++; } parameterModifiers = new ParameterModifier[1] { parameterModifier }; return(actualParameters); }
private void ProcessParameters(ActivityExecutionContext context, IMethodMessage message, Type interfaceType, string operation) { WorkflowParameterBindingCollection parameterBindings = this.ParameterBindings; if (parameterBindings != null) { MethodInfo method = interfaceType.GetMethod(operation); if (method != null) { int num = 0; bool flag = false; foreach (ParameterInfo info2 in method.GetParameters()) { if (!info2.ParameterType.IsByRef && (!info2.IsIn || !info2.IsOut)) { if (parameterBindings.Contains(info2.Name)) { WorkflowParameterBinding binding = parameterBindings[info2.Name]; binding.Value = message.Args[num++]; } } else { flag = true; } } if ((method.ReturnType != typeof(void)) || flag) { IComparable queueName = new EventQueueName(interfaceType, operation, base.QualifiedName); WorkflowQueuingService service = (WorkflowQueuingService)context.GetService(typeof(WorkflowQueuingService)); if (!service.Exists(queueName)) { service.CreateWorkflowQueue(queueName, true); } service.GetWorkflowQueue(queueName).Enqueue(message); } } } }
internal static object[] GetParameters(MethodBase methodBase, WorkflowParameterBindingCollection parameterBindings, out ParameterModifier[] parameterModifiers) { ParameterInfo[] parameters = methodBase.GetParameters(); object[] objArray = new object[parameters.Length]; if (objArray.Length == 0) { parameterModifiers = new ParameterModifier[0]; return(objArray); } int index = 0; BinaryFormatter formatter = null; ParameterModifier modifier = new ParameterModifier(objArray.Length); foreach (ParameterInfo info in parameters) { if (info.ParameterType.IsByRef) { modifier[index] = true; } else { modifier[index] = false; } if (parameterBindings.Contains(info.Name)) { WorkflowParameterBinding binding = parameterBindings[info.Name]; if (formatter == null) { formatter = new BinaryFormatter(); } objArray[index] = CloneOutboundValue(binding.Value, formatter, info.Name); } index++; } ParameterModifier[] modifierArray = new ParameterModifier[] { modifier }; parameterModifiers = modifierArray; return(objArray); }
private static bool ProcessEventParameters(WorkflowParameterBindingCollection parameters, IMethodMessage message, Type interfaceType, string operation) { bool flag = false; if (parameters != null) { MethodInfo method = interfaceType.GetEvent(operation).EventHandlerType.GetMethod("Invoke"); int index = 0; foreach (ParameterInfo info3 in method.GetParameters()) { if (typeof(ExternalDataEventArgs).IsAssignableFrom(info3.ParameterType) && (index == 1)) { flag = true; } if (parameters.Contains(info3.Name)) { WorkflowParameterBinding binding = parameters[info3.Name]; binding.Value = message.Args[index]; } index++; } } return(flag); }
public override void SetValue(object component, object value) { // the logic for notifications is borrowed from ReflectPropertyDescritpor if (component == null) { return; } IServiceProvider serviceProvider = GetSite(component); ComponentChangeDispatcher componentChange = (serviceProvider != null) ? new ComponentChangeDispatcher(serviceProvider, component, this) : null; try { WorkflowParameterBindingCollection parameters = GetParameterBindings(component); if (parameters != null) { string propertyName = String.Empty; if (this.Name.StartsWith(parameterPrefix, StringComparison.Ordinal)) { propertyName = this.Name.Substring(parameterPrefix.Length); } else { propertyName = this.Name; } WorkflowParameterBinding binding = null; if (parameters.Contains(propertyName)) { binding = parameters[propertyName]; } else { binding = new WorkflowParameterBinding(propertyName); parameters.Add(binding); } if (value is ActivityBind) { binding.SetBinding(WorkflowParameterBinding.ValueProperty, value as ActivityBind); } else { binding.SetValue(WorkflowParameterBinding.ValueProperty, value); } OnValueChanged(component, EventArgs.Empty); } } catch (Exception t) { // If there was a problem setting the controls property then we get: // ArgumentException (from properties set method) // ==> Becomes inner exception of TargetInvocationException // ==> caught here // Propagate the original exception up if (t is TargetInvocationException && t.InnerException != null) { throw t.InnerException; } else { throw t; } } finally { // Now notify the change service that the change was successful. if (componentChange != null) { componentChange.Dispose(); } } }
public override void SetValue(object component, object value) { if (component != null) { ISite site = GetSite(component); IComponentChangeService changeService = null; if (site != null) { changeService = (IComponentChangeService)site.GetService(typeof(IComponentChangeService)); } // Raise the OnComponentChanging event changeService.OnComponentChanging(component, this); // Save the old value object oldValue = GetValue(component); try { WorkflowParameterBindingCollection parameters = GetParameters(component); if (parameters != null) { if (value == null) { // Remove the binding from the ParameterBindings collection parameters.Remove(this.Name); } else { // Add the binding to the ParameterBindings collection WorkflowParameterBinding binding = null; if (parameters.Contains(this.Name)) { binding = parameters[this.Name]; } else { binding = new WorkflowParameterBinding(this.Name); parameters.Add(binding); } // Set the binding value on the ParameterBindings collection correspondent binding item if (value is ActivityBind) { binding.SetBinding(WorkflowParameterBinding.ValueProperty, value as ActivityBind); } else { binding.SetValue(WorkflowParameterBinding.ValueProperty, value); } } } // Raise the OnValueChanged event OnValueChanged(component, EventArgs.Empty); } catch (Exception) { value = oldValue; throw; } finally { if (changeService != null) { // Raise the OnComponentChanged event changeService.OnComponentChanged(component, this, oldValue, value); } } } }
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { if (executionContext == null) { throw new ArgumentNullException("executionContext"); } WorkflowQueuingService service = executionContext.GetService <WorkflowQueuingService>(); base.RaiseEvent(SendingOutputEvent, this, EventArgs.Empty); WebServiceInputActivity activityByName = base.GetActivityByName(this.InputActivityName) as WebServiceInputActivity; if (activityByName == null) { for (Activity activity2 = base.Parent; activity2 != null; activity2 = base.Parent) { string activityQualifiedName = activity2.QualifiedName + "." + this.InputActivityName; activityByName = base.GetActivityByName(activityQualifiedName) as WebServiceInputActivity; if (activityByName != null) { break; } } } if (activityByName == null) { throw new InvalidOperationException(SR.GetString("Error_CannotResolveWebServiceInput", new object[] { base.QualifiedName, this.InputActivityName })); } IComparable queueName = new EventQueueName(activityByName.InterfaceType, activityByName.MethodName, activityByName.QualifiedName); MethodInfo method = activityByName.InterfaceType.GetMethod(activityByName.MethodName); if (!service.Exists(queueName)) { if (method.ReturnType == typeof(void)) { return(ActivityExecutionStatus.Closed); } bool flag = false; foreach (ParameterInfo info2 in method.GetParameters()) { if (info2.ParameterType.IsByRef || (info2.IsIn && info2.IsOut)) { flag = true; } } if (flag) { return(ActivityExecutionStatus.Closed); } } if (!service.Exists(queueName)) { throw new InvalidOperationException(SR.GetString("Error_WebServiceInputNotProcessed", new object[] { activityByName.QualifiedName })); } IMethodResponseMessage message = null; WorkflowQueue workflowQueue = service.GetWorkflowQueue(queueName); if (workflowQueue.Count != 0) { message = workflowQueue.Dequeue() as IMethodResponseMessage; } WorkflowParameterBindingCollection parameterBindings = this.ParameterBindings; ArrayList outArgs = new ArrayList(); if (this.ParameterBindings.Contains("(ReturnValue)")) { WorkflowParameterBinding binding = this.ParameterBindings["(ReturnValue)"]; if (binding != null) { outArgs.Add(binding.Value); } } foreach (ParameterInfo info3 in method.GetParameters()) { if (info3.ParameterType.IsByRef || (info3.IsIn && info3.IsOut)) { WorkflowParameterBinding binding2 = parameterBindings[info3.Name]; outArgs.Add(binding2.Value); } } message.SendResponse(outArgs); return(ActivityExecutionStatus.Closed); }
protected override sealed ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { if (executionContext == null) { throw new ArgumentNullException("executionContext"); } if (SessionId != "" && SessionId != null) { PopulateSessionCookie(); } // Create instance of Proxy. object proxyInstance = Activator.CreateInstance(this.ProxyClass); //Set Session Cookie System.Web.Services.Protocols.HttpWebClientProtocol proxy = proxyInstance as System.Web.Services.Protocols.HttpWebClientProtocol; System.Diagnostics.Debug.Assert(proxy != null); proxy.CookieContainer = this.SessionCookieContainer; //Invoke OnBefore Invoke this.RaiseGenericEvent(InvokeWebServiceActivity.InvokingEvent, this, new InvokeWebServiceEventArgs(proxyInstance)); // Get the parameters. MethodInfo methodInfo = this.ProxyClass.GetMethod(this.MethodName, BindingFlags.Instance | BindingFlags.Public); object[] actualParameters = InvokeHelper.GetParameters(methodInfo, this.ParameterBindings); WorkflowParameterBinding resultBinding = null; if (this.ParameterBindings.Contains("(ReturnValue)")) { resultBinding = this.ParameterBindings["(ReturnValue)"]; } Object result = null; try { //Invoke the Web Service. result = this.ProxyClass.InvokeMember(this.MethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, proxyInstance, actualParameters, System.Globalization.CultureInfo.InvariantCulture); } catch (TargetInvocationException e) { if (e.InnerException != null) { throw e.InnerException; } else { throw; } } // Save the result. if (resultBinding != null) { resultBinding.Value = result; } // Save ref parameters. InvokeHelper.SaveOutRefParameters(actualParameters, methodInfo, this.ParameterBindings); //Invoke OnAfter Invoke this.RaiseGenericEvent(InvokeWebServiceActivity.InvokedEvent, this, new InvokeWebServiceEventArgs(proxyInstance)); return(ActivityExecutionStatus.Closed); }
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { if (executionContext == null) { throw new ArgumentNullException("executionContext"); } WorkflowQueuingService queueService = executionContext.GetService <WorkflowQueuingService>(); // fire event this.RaiseEvent(WebServiceOutputActivity.SendingOutputEvent, this, EventArgs.Empty); WebServiceInputActivity webservicereceive = this.GetActivityByName(this.InputActivityName) as WebServiceInputActivity; if (webservicereceive == null) { Activity parent = this.Parent; while (parent != null) { //typically if defined inside a custom activity string qualifiedName = parent.QualifiedName + "." + this.InputActivityName; webservicereceive = this.GetActivityByName(qualifiedName) as WebServiceInputActivity; if (webservicereceive != null) { break; } parent = this.Parent; } } if (webservicereceive == null) { throw new InvalidOperationException(SR.GetString(SR.Error_CannotResolveWebServiceInput, this.QualifiedName, this.InputActivityName)); } IComparable queueId = new EventQueueName(webservicereceive.InterfaceType, webservicereceive.MethodName, webservicereceive.QualifiedName); MethodInfo mInfo = webservicereceive.InterfaceType.GetMethod(webservicereceive.MethodName); if (!queueService.Exists(queueId)) { // determine if no response is required, // compiler did not catch it, do the runtime check and return if (mInfo.ReturnType == typeof(void)) { return(ActivityExecutionStatus.Closed); } bool isresponseRequired = false; foreach (ParameterInfo formalParameter in mInfo.GetParameters()) { if (formalParameter.ParameterType.IsByRef || (formalParameter.IsIn && formalParameter.IsOut)) { isresponseRequired = true; } } if (isresponseRequired) { return(ActivityExecutionStatus.Closed); } } if (!queueService.Exists(queueId)) { throw new InvalidOperationException(SR.GetString(SR.Error_WebServiceInputNotProcessed, webservicereceive.QualifiedName)); } IMethodResponseMessage responseMessage = null; WorkflowQueue queue = queueService.GetWorkflowQueue(queueId); if (queue.Count != 0) { responseMessage = queue.Dequeue() as IMethodResponseMessage; } IMethodMessage message = responseMessage as IMethodMessage; WorkflowParameterBindingCollection parameterBindings = this.ParameterBindings; ArrayList outArgs = new ArrayList(); // populate result if (this.ParameterBindings.Contains("(ReturnValue)")) { WorkflowParameterBinding retBind = this.ParameterBindings["(ReturnValue)"]; if (retBind != null) { outArgs.Add(retBind.Value); } } foreach (ParameterInfo formalParameter in mInfo.GetParameters()) { // update out and byref values if (formalParameter.ParameterType.IsByRef || (formalParameter.IsIn && formalParameter.IsOut)) { WorkflowParameterBinding binding = parameterBindings[formalParameter.Name]; outArgs.Add(binding.Value); } } // reset the waiting thread responseMessage.SendResponse(outArgs); return(ActivityExecutionStatus.Closed); }