Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }