How to get all WebMethods of a WebService pointed by a ServiceReference.Path
In my ASP.NET application, I use the ServiceReferenceCollection
to carry a set of WebServices
, and in the code-behind, I'm asked to figure out all the public WebMethod(s)
and corresponding arguments of the WebServices
by using .Net Reflection. However, the ServiceReference
class provides only Path
information that I c开发者_开发知识库an use for reflection, but I don't know how to GetType()
from Path
.
Path
is a path to asmx file.
You can just open this file as a text file.
<%@ WebService
Language="C#" CodeBehind="MyService.asmx.cs"
Class="Namespace1.Namepsace2.ClassName" %>
Read it as text and parse out class name for the file.
Once you have the class name you can use reflection to iterate through class methods.
Assumed that:
- asmx files are accessible
- web service assembly and types are loaded into app domain
精彩评论