惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
博客园_首页
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
O
OpenAI News
阮一峰的网络日志
阮一峰的网络日志
小众软件
小众软件
S
Securelist
博客园 - 叶小钗
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 热门话题
Jina AI
Jina AI
博客园 - 【当耐特】
C
Cisco Blogs
爱范儿
爱范儿
Scott Helme
Scott Helme
月光博客
月光博客
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
J
Java Code Geeks
T
Tailwind CSS Blog
S
Schneier on Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Privacy & Cybersecurity Law Blog
T
Threatpost
IT之家
IT之家
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - Franky
V
Vulnerabilities – Threatpost
V
Visual Studio Blog
P
Proofpoint News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
MongoDB | Blog
MongoDB | Blog
Stack Overflow Blog
Stack Overflow Blog
G
Google Developers Blog
T
Tor Project blog
The Hacker News
The Hacker News
NISL@THU
NISL@THU
腾讯CDC
SecWiki News
SecWiki News
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News

博客园 - 孤城浪子

[转].Net 中的许可证机制 [原]一步一步自己制作弹出框 [转]获取窗口 高 、宽 的JS代码 PHP连接mysql数据库 - 孤城浪子 - 博客园 PHP文件上传 [转]ASP.NET 2.0 下加密解密算法的封装 [转]fckeidtor配置 [转]加解密技术 - 孤城浪子 - 博客园 [转]服务器推技术 [JavaScript]简单跟随鼠标移动的文字 排序算法 [仿照CloudGamer]写的颜色渐变 Asp.Net用SmtpClient发送邮件 项目中遇到的Vss和Sql问题 [JavaScript]拖动对象 - 孤城浪子 - 博客园 [JavaScript]飘浮文字 C#文件打散合并 C#调用Excel的宏 [网上整理]C#合并Excel
动态调用Web Service - 孤城浪子 - 博客园
孤城浪子 · 2010-01-05 · via 博客园 - 孤城浪子

代码

 System.Net.WebClient wc = new System.Net.WebClient();
        System.IO.Stream stream 
= wc.OpenRead("http://localhost:44763/Jquery/DynamicInvoke.asmx?WSDL");
        
//获取Web服务描述
        System.Web.Services.Description.ServiceDescription sd =System.Web.Services.Description.ServiceDescription.Read(stream);
        System.Web.Services.Description.ServiceDescriptionImporter sdi 
= new System.Web.Services.Description.ServiceDescriptionImporter();
        sdi.AddServiceDescription(sd, 
"""");
        System.CodeDom.CodeNamespace ns 
= new System.CodeDom.CodeNamespace();
        System.CodeDom.CodeCompileUnit cu 
= new System.CodeDom.CodeCompileUnit();
        cu.Namespaces.Add(ns);
        sdi.Import(ns, cu);
//导入指定的web服务描述
        
//创建csharp代码提供程序
        Microsoft.CSharp.CSharpCodeProvider provider = new Microsoft.CSharp.CSharpCodeProvider();
        
//创建csharp代码编译器
        System.CodeDom.Compiler.ICodeCompiler compiler = provider.CreateCompiler();//调用参数设置
        System.CodeDom.Compiler.CompilerParameters parms = new System.CodeDom.Compiler.CompilerParameters();
        parms.GenerateExecutable 
= false;
        parms.GenerateInMemory 
= true;

        parms.ReferencedAssemblies.Add(

"System.dll");
        parms.ReferencedAssemblies.Add(
"System.XML.dll");
        parms.ReferencedAssemblies.Add(
"System.Web.Services.dll");
        parms.ReferencedAssemblies.Add(
"System.Data.dll");//生成程序集
        System.CodeDom.Compiler.CompilerResults result = provider.CompileAssemblyFromDom(parms, cu);
        
if (true == result.Errors.HasErrors)
        {
 
        }

        System.Reflection.Assembly assembly 

= result.CompiledAssembly;
        Type t 
= assembly.GetType("DynamicInvoke"truetrue);
        
object obj = Activator.CreateInstance(t);
        System.Reflection.MethodInfo mi 
= t.GetMethod("HelloWorld");
        Response.Write(mi.Invoke(obj, 
null));