日期:2014-05-17  浏览次数:20358 次

在SQL2008Clr 存储过程中动态调用WebService
我写了一上存储过程,很简单,
就是传入一个服务URL
通过个URL动态调用远程WebService
动态调用的类是在网上找的,一大堆,在C#程序中是没问题的
但同样的方法在CLR存储过程中无效,具体如下:
 /// < summary> 
        /// 动态调用web服务 
        /// < /summary> 
        /// < param name="url">WSDL服务地址< /param> 
        /// < param name="classname">类名< /param> 
        /// < param name="methodname">方法名< /param> 
        /// < param name="args">参数< /param> 
        /// < returns>< /returns> 
        public static object InvokeWebService(string url, string classname, string methodname, object[] args)
        {
            string @namespace = "EnterpriseServerBase.WebService.DynamicWebCalling";
            if ((classname == null) || (classname == ""))
            {
                classname = WSHelper.GetWsClassName(url);
            }
            try
            {
                //获取WSDL 
                WebClient wc = new WebClient();
                Uri uri = new Uri(url + "?WSDL");
                Stream stream = wc.OpenRead(uri);

                // 2. 创建和格式化 WSDL 文档。
                ServiceDescription sd = ServiceDescription.Read(stream);