Example #1
0
 protected object[] Invoke(string name,  params object[] parameters)
 {
     var type = (DTypeDesc) Context.Items["SoapServerType"];
     var method = type.GetMethod(new Name(name));
     var clrMethod = WsdlHelper.GetMethodBySoapName(name, GetType());
     var p = ResultBinder.BindServerParameters(parameters, clrMethod);
     var context = ScriptContext.CurrentContext;
     context.Stack.AddFrame(p);
     var result = Convert.ObjectToPhpArray(method.Invoke(null, context.Stack));
     var binder = new ParameterBinder();
     var results = binder.BindServerResult(clrMethod, result, true);
     return results;
 }
        /// <summary>
        /// Invokes the call.
        /// </summary>
        /// <returns></returns>
        public object InvokeCall(string methodName, PhpArray parameters)
        {
            var        soapProxy = (SoapHttpClientProtocolExtended)proxyInstance;
            MethodInfo mi        = soapProxy.GetType().GetMethod(methodName);

            bool wrappedArgs = true;

            object[] attr = mi.GetCustomAttributes(typeof(System.Web.Services.Protocols.SoapDocumentMethodAttribute), false);
            if (attr.Length > 0 && attr[0].GetType() == typeof(System.Web.Services.Protocols.SoapDocumentMethodAttribute))
            {
                var soapMethodAttr = (System.Web.Services.Protocols.SoapDocumentMethodAttribute)attr[0];
                if (soapMethodAttr.ParameterStyle == System.Web.Services.Protocols.SoapParameterStyle.Bare)
                {
                    wrappedArgs = false;
                }
            }


            var paramBinder = new ParameterBinder();

            object[] transformedParameters = paramBinder.BindParams(mi, parameters, wrappedArgs);


            object[] resArray = soapProxy.Invoke(methodName, transformedParameters);

            if (resArray[0] != null)
            {
                resArray[0] = ResultBinder.BindResult(
                    resArray[0],
                    mi.Name,
                    wrappedArgs);
            }

            //object result = mi.Invoke(proxyInstance, (object[])methodParams.ToArray(typeof(object)));

            //foreach (ParameterInfo pi in mi.GetParameters())
            //{
            //    if (pi.IsOut) outParams.Add(methodParams[i]);

            //    i++;
            //}

            return(resArray[0]);
        }
        /// <summary>
        /// Invokes the call.
        /// </summary>
        /// <returns></returns>
        public object InvokeCall(string methodName ,PhpArray parameters)
        {
            var soapProxy = (SoapHttpClientProtocolExtended)proxyInstance;
            MethodInfo mi = soapProxy.GetType().GetMethod(methodName);

            bool wrappedArgs = true;

            object[] attr = mi.GetCustomAttributes(typeof(System.Web.Services.Protocols.SoapDocumentMethodAttribute), false);
            if (attr.Length > 0 && attr[0].GetType() == typeof(System.Web.Services.Protocols.SoapDocumentMethodAttribute))
            {
                var soapMethodAttr = (System.Web.Services.Protocols.SoapDocumentMethodAttribute)attr[0];
                if (soapMethodAttr.ParameterStyle == System.Web.Services.Protocols.SoapParameterStyle.Bare)
                {
                    wrappedArgs = false;
                }
            }


            var paramBinder = new ParameterBinder();
            object[] transformedParameters = paramBinder.BindParams(mi, parameters, wrappedArgs);


            object[] resArray = soapProxy.Invoke(methodName, transformedParameters);

            if (resArray[0] != null)
            {
                resArray[0] = ResultBinder.BindResult( 
                    resArray[0],
                    mi.Name,
                    wrappedArgs);
            }

            //object result = mi.Invoke(proxyInstance, (object[])methodParams.ToArray(typeof(object)));

            //foreach (ParameterInfo pi in mi.GetParameters())
            //{
            //    if (pi.IsOut) outParams.Add(methodParams[i]);

            //    i++;
            //}
                
            return resArray[0];
        }