lundi 15 mai 2017

Invoke WebService Method With reflection

I got a service that takes the services and test the method. In my services method i use SoapHeaderAttribute for security.

How do i pass the soapheaderattribute when i invoke method with reflection? Here is my code.

object result = null;
                                ParameterInfo[] parameters = methodInfo.GetParameters();
                                object classInstance = Activator.CreateInstance(type, null);


                                if (parameters.Length == 0)
                                {
                                    result = methodInfo.Invoke(classInstance, null);
                                }
                                else
                                {
                                    object[] parametersArray = ((TestMethodAttribute)methodInfo.GetCustomAttribute(typeof(TestMethodAttribute))).parametreDegerleri;


                                    result = methodInfo.Invoke(classInstance, parametersArray);
                                }





Aucun commentaire:

Enregistrer un commentaire