下载中心┊文章中心┊软件分类┊更新软件┊推荐下载┊热门软件┊更新文章┊热门文章
 
《拓文asp.net网站内容管理系统》官方演示站。
 设为首页    
 收藏本站
 作者:黄振安
 
网站首页 开源拓文 .NET编程 网站编程 网页设计 图形图像 数据库 软件工程留言本
    站内搜索:   
您现在的位置: 拓文网络 → 文章中心 → .NET编程 → Web Services → 动态调用Webservice[正文]

热 门 文 章

相 关 文 章
没有相关文章!
动态调用Webservice
 
[作者:不详    转贴自:不详    点击数:    字体:【大 中 小】    更新时间:2006-4-3 15:46:42]

/// <summary>
  /// 根据指定的信息,调用远程webservice方法
  /// </summary>
  /// <param name="url">webservice的http形式的地址</param>
  /// <param name="namespace">欲调用的webservice的命名空间</param>
  /// <param name="classname">欲调用的webservice的类名(不包括命名空间前缀)</param>
  /// <param name="methodname">欲调用的webservice的方法名</param>
  /// <param name="args">参数列表</param>
  /// <returns>webservice的执行结果</returns>
  /// <remarks>
  /// 如果调用失败,将会抛出exception。请调用的时候,适当截获异常。
  /// 异常信息可能会发生在两个地方:
  /// 1、动态构造webservice的时候,compileassembly失败。
  /// 2、webservice本身执行失败。
  /// </remarks>
  /// <example>
  /// <code>
  /// object obj = invokewebservice("http://localhost/gsp_workflowwebservice/common.asmx","genersoft.platform.service.workflow","common","gettooltype",new object[]{"1"});
  /// </code>
  /// </example>
  private object invokewebservice(string url, string @namespace, string classname, string methodname, object[] args)
  {       
   try
   {
    system.net.webclient wc = new system.net.webclient();
    system.io.stream stream = wc.openread(url+"?wsdl");
    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 cn = new system.codedom.codenamespace(@namespace);
    system.codedom.codecompileunit ccu = new system.codedom.codecompileunit();
    ccu.namespaces.add(cn);
    sdi.import(cn,ccu);


    microsoft.csharp.csharpcodeprovider csc = new microsoft.csharp.csharpcodeprovider();
    system.codedom.compiler.icodecompiler icc = csc.createcompiler();


    system.codedom.compiler.compilerparameters cplist = new system.codedom.compiler.compilerparameters();
    cplist.generateexecutable = false;
    cplist.generateinmemory = true;
    cplist.referencedassemblies.add("system.dll");
    cplist.referencedassemblies.add("system.xml.dll");
    cplist.referencedassemblies.add("system.web.services.dll");
    cplist.referencedassemblies.add("system.data.dll");


页次:1/2  1篇/页  首页   上一页   下一页   尾页  合计 2 篇 Go:
 
上一篇:AJAX应用解决一些常见问题
下一篇:CSS的十八般技巧
winner 打印本页 关闭窗口

     文 章 评 论
评论人 查看该文章的评论 发表时间
   笔 名* : 0 50分 60分 70分 80分 90分 100分
评论内容 *: (最多600字。当前字数:0)


没有相关评论,欢迎您参与!

- 关于本站 - 网站帮助 - 下载声明 - 友情连接 - 网站地图 -
Copyright © 2005-2006 myTopWin.Com. All Rights Reserved . [桂ICP备06004496号]