Tuesday, September 20, 2005

Dynamically invoke XML Web Services - significantly improved

GotDotNet User Sample: Dynamically invoke XML Web Services - significantly improved: "It is pure reflection prgramming in .NET.
E.g.
DynamicWebServiceProxy ws = new DynamicWebServiceProxy();
string ns = 'eYesoft.Tools.Web.Services.DynamicProxy.';

ws.WSDL = 'http://localhost/CTWS/Service1.asmx?WSDL';
ws.TypeName = 'Service1';
ws.MethodName = 'GetOrder';

// get all types of the dynamic assembly
Type[] types = ws.ProxyAssembly.GetTypes();
// get a certain type by name - watch out for fully qualified name
Type t = ws.ProxyAssembly.GetType(ns + 'Order');
...

Then create an instance of the type by using reflection.

object result = Activator.CreateInstance(t);
result = ws.InvokeCall();

Christian "
Post a Comment