Exemplo n.º 1
0
        public MethodTracker(Method theMethod, Dictionary<Type, object[]> parameterLibrary, WebServiceCallListener listener)
        {
            this._listener = listener;
            this._theMethod = theMethod;
            this._parametersToFuzz = theMethod.Parameters;
            this._ParameterCount = this._parametersToFuzz.Count;

            this._parameterLibrary = parameterLibrary;

            _parameterCurrents = new int[ParameterCount];
            for (int i = 0; i < ParameterCount; i++)
            {
                _parameterCurrents[i] = 0;
            }

            _parameterValueCounts = new int[ParameterCount];

            int valueCounter = 0;
            foreach (Parameter p in _parametersToFuzz)
            {
                object[] parameterValues = parameterLibrary[p.Type];
                if (parameterValues == null)
                {
                    throw new ArgumentException("No parameter values available for type: "
                                                    + p.Type + " required by parameter: " + p.Name);
                }

                _parameterValueCounts[valueCounter] = parameterValues.Length;

                valueCounter++;
            }
        }
Exemplo n.º 2
0
        public void HandleCall(Method method, object[] parameters, string requestText, string responseText, Exception exception)
        {
            if (exception != null)
            {
                // Log("Method: " + method + ", parameters: " + parameters + ", requestText: " + requestText + ", responseText: " + responseText + ", exception: " + exception);
                Log("Call to " + method.Name + " failed!  Parameters were: " + parameters + " and responseText was: " + responseText);
                _failedCalls++;
            }
            else
            {
                Log("Call to " + method.Name + " ran fine");
                _successfulCalls++;
            }

            if (exception != null || _storeAll == true)
            {
                Guid id = Guid.NewGuid();
                SqlConnection conn = GetConnection();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "up_CreateWebServicesCall";
                cmd.Connection = conn;
                cmd.Parameters.Add(new SqlParameter("ID", id));
                cmd.Parameters.Add(new SqlParameter("SessionID", _sessionId));
                cmd.Parameters.Add(new SqlParameter("MethodName", method.Name));
                cmd.Parameters.Add(new SqlParameter("Parameters", FormatParams(parameters)));
                cmd.Parameters.Add(new SqlParameter("RequestText", requestText));
                cmd.Parameters.Add(new SqlParameter("ResponseText", responseText));
                if (exception != null)
                {
                    cmd.Parameters.Add(new SqlParameter("ExceptionMessage", exception.InnerException.Message));
                    cmd.Parameters.Add(new SqlParameter("ExceptionStackTrace", exception.InnerException.StackTrace));
                }
                cmd.ExecuteNonQuery();
                conn.Dispose();
            }
        }
Exemplo n.º 3
0
        public WebServiceCollection Enumerate()
        {
            //  Clear the cache every time.  If we are running this on a site we should
            //  be seeing everything for the first time (hence no cache benefit), and
            //  for development the cache just causes problems with changes not being
            //  recognized.
            try
            {
                DynamicWebServiceProxy.ClearCache(WSDL);
            }
            catch
            {
                //  The file handling in the DynWSLib cache is kind of strange, so this usually isn't a
                //  big problem.  Usually  :)  It often means that the DLL has already been loaded by this
                //  process and can't be unloaded.
            }

            StringBuilder text = new StringBuilder();

            DynamicProxy.EnableMessageAccess = true;
            DynamicProxy.Wsdl = WSDL;

            Type[] types = DynamicProxy.ProxyAssembly.GetTypes();

            foreach (Type t in types)
            {
                WebService currentWebService;

                if (t.BaseType == typeof(SoapHttpClientProtocolExtended))
                {
                    text.Append("Found a WebService: ");
                    text.Append(t.Name);
                    text.Append("\n");

                    // Services.WebServices.Add(new WebService(t.Name));
                    currentWebService = new WebService(Services, t.Name);
                    Services.WebServices.Add(currentWebService);

                    MethodInfo[] mi = t.GetMethods(BindingFlags.Public |
                                    BindingFlags.Instance |
                                    BindingFlags.DeclaredOnly);

                    foreach (MethodInfo m in mi)
                    {
                        if (!(m.Name.StartsWith("Begin") || m.Name.StartsWith("End")))
                        {
                            text.Append("Found a method: ");
                            text.Append(m.Name);
                            text.Append(" with return type: ");
                            text.Append(m.ReturnType);
                            text.Append("\n");

                            Method currentMethod = new Method(currentWebService, m.Name, m.ReturnType);
                            currentWebService.Methods.Add(currentMethod);

                            ParameterInfo[] pi = m.GetParameters();
                            // paramInfo = pi;

                            foreach (ParameterInfo p in pi)
                            {
                                text.Append("Found a parameter: ");
                                text.Append(p.Name);
                                text.Append(":");
                                text.Append(p.ParameterType);
                                text.Append("\n");

                                Parameter currentParameter;
                                currentParameter = new Parameter(p.Name, p.ParameterType);
                                currentMethod.Parameters.Add(currentParameter);
                            }
                        }
                    }
                }
                else
                {
                    text.Append("Found non-standard Type: ");
                    text.Append(t.Name);
                    text.Append("\n");
                }
            }

            //  TODO - Make this have no return value and use the WebServicesCollection.ToString instead.
            System.Console.WriteLine(text.ToString());
            // return (text.ToString());
            return (_Services);
        }
Exemplo n.º 4
0
 private void lstMethods_SelectedIndexChanged(object sender, EventArgs e)
 {
     System.Windows.Forms.ListControl realSender = (System.Windows.Forms.ListControl)sender;
     string name = realSender.Text;
     Method ws = null;
     foreach (Method myMethod in this._currentWs.Methods)
     {
         if (name.Equals(myMethod.Name))
         {
             this._currentMethod = myMethod;
             this.lstParameters.Items.Clear();
             foreach (Parameter p in myMethod.Parameters)
             {
                 lstParameters.Items.Add(p.ToString());
             }
         }
     }
 }