Example #1
0
        protected override string Post(ServiceProxyInvokeEventArgs invokeArgs, HttpWebRequest request)
        {
            string baseAddress = invokeArgs.BaseAddress;
            string className   = invokeArgs.ClassName;
            string methodName  = invokeArgs.MethodName;

            object[] parameters = invokeArgs.PostParameters;
            if (className.Equals("securechannel", StringComparison.InvariantCultureIgnoreCase) && methodName.Equals("invoke", StringComparison.InvariantCultureIgnoreCase))
            {
                // the target is the SecureChannel.Invoke method but we
                // need the actual className and method that is in the parameters
                // object
                string   actualClassName  = (string)parameters[0];
                string   actualMethodName = (string)parameters[1];
                string   jsonParams       = (string)parameters[2];
                HttpArgs args             = new HttpArgs();
                args.ParseJson(jsonParams);

                if (TypeRequiresApiKey || MethodRequiresApiKey(actualMethodName))
                {
                    ApiKeyResolver.SetKeyToken(request, ApiParameters.GetStringToHash(actualClassName, actualMethodName, args["jsonParams"]));
                }
            }
            return(base.Post(invokeArgs, request));
        }
Example #2
0
        protected internal override string DoInvoke(ServiceProxyInvokeEventArgs args)
        {
            string baseAddress = args.BaseAddress;
            string className   = args.ClassName;
            string methodName  = args.MethodName;

            object[] parameters = args.PostParameters;
            ServiceProxyInvokeEventArgs secureChannelArgs = new ServiceProxyInvokeEventArgs {
                Cuid = args.Cuid, BaseAddress = baseAddress, ClassName = typeof(SecureChannel).Name, MethodName = "Invoke", PostParameters = new object[] { className, methodName, ApiParameters.ParametersToJsonParamsObjectString(parameters) }
            };

            try
            {
                SecureChannelMessage <string> result = Post(secureChannelArgs).FromJson <SecureChannelMessage <string> >();
                if (result.Success)
                {
                    Decrypted decrypted = new Decrypted(result.Data, SessionKey, SessionIV);
                    return(decrypted.Value);
                }
                else
                {
                    string properties = result.PropertiesToString();
                    throw new ServiceProxyInvocationFailedException("{0}"._Format(result.Message, properties));
                }
            }
            catch (Exception ex)
            {
                args.Exception = ex;
                args.Message   = ex.Message;
                OnInvocationException(args);
            }

            return(string.Empty);
        }
Example #3
0
 private void InvocationHandler(object sender, ServiceProxyInvokeEventArgs args)
 {
     FireEvent(MethodInvoked, sender, args);
 }
Example #4
0
 private void InvocationExceptionHandler(object sender, ServiceProxyInvokeEventArgs args)
 {
     FireEvent(InvocationException, sender, args);
 }