Reputation: 165
I have created proxy web service in my project. I want to call method name from parameter as a string and I need to get response from these methods, but it returns as a string only. So please anyone help me.
Here I need to pass MethodName.
for eg:
string response = mut.MethodName(RequestData);
[WebMethod]
public string CALLPROXY(string MethodName, string RequestData)
{
WebReference.IMPSMethods mut = new WebReference.IMPSMethods();
mut.Url = "http://xxxxxxxxxxx.asmx?wsdl";
mut.Credentials = System.Net.CredentialCache.DefaultCredentials;
//string response = mut.LOGIN(RequestData);
string response = mut + "." + MethodName + "(" + RequestData + ")";
return response;
}
Upvotes: 4
Views: 723
Reputation: 27367
Try this
string response = typeof(WebReference.IMPSMethods)
.GetMethod(MethodName)
.Invoke(mut, new object[] { RequestData })
If your class IMPSMethods
has overloads, you will need to use the overloaded .GetMethod() call to narrow it down (looking for particular parameter types, etc).
Upvotes: 2