通过使用 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接口。也可以仅仅包含接口所有的同名同参数,同返回值得的函数、属性。(事件应该是无效的。呵呵)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。