How can I show all the methods that are available in my WCF in a dropdown. I need to show only those methods that are exposed to the client. I have the following code working, but it displays much more methods than expected. Seems it displays all.
MethodInfo[] methods = typeof(IntlService.ClientDataServiceClient).GetMethods();
//// sort methods by name
Array.Sort(methods,
delegate(MethodInfo methods1, MethodInfo methods2)
{ return methods1.Name.CompareTo(methods2.Name); });
foreach (var method in methods)
{
string methodName = method.Name;
ddlMethods.Items.Add(methodName);
}
How can I restrict the display to show only the ones that I defined
If you’re looking to get only methods defined by your class, in this case,
IntlService.ClientDataServiceClient, then alter your call toGetMethods()like this:If you’re looking to get only methods that are declared as service methods, then you’ll need to examine the attributes on the methods: