加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

WebServices 动态调用 接口自动创建 EMIT

发布时间:2020-12-17 02:00:00 所属栏目:安全 来源:网络整理
导读:? 通过使用 System.Reflection.Emit 动态创建代码,实现从WebService对象上抽离接口。从而方便实用。 using System;using System.Reflection;using System.IO;using System.Web;using System.CodeDom;using System.CodeDom.Compiler;using System.Collection

?

通过使用 System.Reflection.Emit 动态创建代码,实现从WebService对象上抽离接口。从而方便实用。

?

实际使用代码

??????????? string wsdl = @"http://localhost/FSQS_WebService/Service.asmx?WSDL ";
??????????? ITableWritor obj = DynWebService.GetWebServiceInterface<ITableWritor>(wsdl,"Service");
??????????? string info = obj.TestConnection();

?

其中ITableWritor?是如下接口

?

?public interface ITableWritor
??? {
??????? void UpdataTable(string clientID,string targetTableName,string srcName,DataTable sourceContent);
??????? string UpdataFile(string clientID,string srcname,string bufferFilePath,int type);
??????? string TestConnection();
??? }

?

其中"Service" 是asmx文件中对应的类的类名。类"Service"上可以显示实现ITableWritor接口。也可以仅仅包含接口所有的同名同参数,同返回值得的函数、属性。(事件应该是无效的。呵呵)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读