Dynamically readable web service methods

Is there a way to dynamically read web service methods using a program? I have a Windows Forms application that should be able to read a list of methods and display them. I added a service link for my project, but you need help reading a list of web methods or operations (WCFs).


Answer:

Here is a snippet of code just in case someone is looking for it.

MethodInfo[] methods = typeof(MyClass).GetMethods(BindingFlags.Public | BindingFlags.Instance); if (methods != null && methods.Length > 0) { foreach (MethodInfo m in methods) { foreach (object o in m.GetCustomAttributes(false)) { // To identify the method if (o.GetType().Name.Equals("SoapDocumentMethodAttribute")) { // Get Name using m.Name } } } } 
+4
source share
2 answers

On your client side, since you already have the type of web link for the web service, you can simply use reflection to list all the methods in the proxy client class.

+2
source

Alternatively, if you need to read service methods on the fly, this article may be of interest to you because it illustrates how to create a WCF proxy server from WSDL. http://blogs.msdn.com/b/vipulmodi/archive/2008/10/16/dynamic-proxy-and-memory-footprint.aspx

You can then use reflection (as suggested by Mike) to read the list of service methods open by the service.

+3
source

Source: https://habr.com/ru/post/1344129/


All Articles