动态调用WebService
方案一:
优点:可以根据需求灵活调用Java或者.Net WebService;客户端调用WebService方法简单
缺点:每次我都要把想调用的函数的参数组织成一个object[]才行,且每次调用InvokeWebService都是在内存中创建动态程序集(代理),效率低。
调用WebService方法 |
InvokeWebService |
/// <summary> /// 获取WebService类型 20101223 /// </summary> /// <param name="wsUrl">WebService地址</param> /// <returns></returns> private static string GetWsClassName(string wsUrl) { string[] parts = wsUrl.Split('/'); string[] pps = parts[parts.Length - 1].Split('.');
return pps[0]; }
/// <summary> /// 调用WebService 20101223 /// </summary> /// <param name="wsUrl">WebService地址</param> /// <param name="methodName">方法名称</param> /// <param name="args">参数列表</param> /// <returns></returns> public static string InvokeWebService(string wsUrl, string methodName, object[] args) { return InvokeWebService(wsUrl, null, methodName, args); }
/// <summary> /// 调用WebService 20101223 /// </summary> /// <param name="wsUrl">WebService地址</param> /// <param name="className">类名</param> /// <param name="methodName">方法名称</param> /// <param name="args">参数列表</param> /// <returns></returns> public static string InvokeWebService(string wsUrl, string className, string methodName, object[] args) { string @namespace = "EnterpriseServerBase.WebService.DynamicWebCalling"; if ((className == null) || (className == "")) { |