Tag: dynamic proxy

来自WSDL的详细ServiceDescription / Proxy

我使用ServiceDescription / ServiceDescriptionImporter类来动态调用Web服务。 我想更深入地了解WSDL描述并得到 1)每个Web方法的参数信息 2)所有Web方法的每个参数的实际类型/组成(即,如果WebMethod将某些复杂类型作为参数,我需要知道它由原型/其他类型组成,如果可能的话) 这是动态调用的代码: public static object CallWebService(string webServiceAsmx, string serviceName, string methodName, object[] args = null) { WebClient client = new WebClient(); Stream stream = client.OpenRead(webServiceAsmx + “?wsdl”); ServiceDescription description = ServiceDescription.Read(stream); ServiceDescriptionImporter importer = new ServiceDescriptionImporter(); importer.ProtocolName = “Soap12”; importer.AddServiceDescription(description, null, null); importer.Style = ServiceDescriptionImportStyle.Client; importer.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties; 我已经能够找到一些基本信息,如方法名称,参数信息,但我需要更深入的分析。 例如,我需要访问Wsdl.exe在代理类中生成的基本上所有信息,但我不想运行Wsdl.exe,只是动态发现信息。 […]

Castle Dynamic Proxy在从类中调用时不拦截方法调用

使用Castle的动态代理时,我遇到了一些(我认为)奇怪的行为。 使用以下代码: class Program { static void Main(string[] args) { var c = new InterceptedClass(); var i = new Interceptor(); var cp = new ProxyGenerator().CreateClassProxyWithTarget(c, i); cp.Method1(); cp.Method2(); Console.ReadLine(); } } public class Interceptor : IInterceptor { public void Intercept(IInvocation invocation) { Console.WriteLine(string.Format(“Intercepted call to: ” + invocation.Method.Name)); invocation.Proceed(); } } public class InterceptedClass { […]