动态网站制作指南 [  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Java教程
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ Java教程 ]的信息

本月文章推荐
.Java技术与XML常见问题之JAXM.
.基于Java的移动游戏开发入门.
.关于常见的Java/J2EE中文问题解决.
.Servlet 技术.
.Java Bean 映射工具&n.
.JavaScript escape/unescape编码.
.实战Visual Basic.Net对话框.
.用 WebSphere Studio 创建 JSF 提.
.细说Web应用开发的一致框架Tapes.
.Java也存在2000年问题.
.我的JAVA工具.
.升级到Hibernate3.0的理由.
.Abstractclass和interface在Java.
.Java中的Stack.
.运用反射实现ejb动态委派(1).
.Java动画中消除闪烁的两个绝招.
.java api 接口篇(二)下.
.使用Java操作文本文件.
.Ant与Eclipse集成解析(1).
.update 和 saveOrUpdate 项目思路.

Eclipse插件实现Axis WebService客户端

发表日期:2008-1-5 |



  1 建立Eclipse插件
  
  File->New->Project->Plug-in development的Plug-in project->Next,填写Project名,Next, 填写内容,Next,选择Create plug-in using one of the templates,选择Hello,World,Finish。
  
  在视图可看到plugin.XML,在里加上运行调用Web Service所需jar包。内容如下:
  
  
  
  
  
    
  id="colimas_plugin"
  
  name="Colimas_plugin Plug-in"
  
  version="1.0.0"
  
  provider-name="nova"
  
  class="colimas_plugin.Colimas_pluginPlugin">
  
  
  
  
  
  
  
  

  
  
  
  
  
  

  
  
  
  
  
  

  
  
  
  
  
  

  
  
  
  
  
  

  
  
  
  
  
  

  
  
  
  
  
  

  
  
  
  
  
  

  
  
  
  
  
  

  
  
  
  
  
  

  
  
  
  
  
  

  
  

  
  
  
  
  
  
  
  

  
    
  point="org.eclipse.ui.actionSets">
  
    
  label="Sample Action Set"
  
  visible="true"
  
  id="colimas_plugin.actionSet">
  
    
  label="Sample &Menu"
  
  id="sampleMenu">
  
    
  name="sampleGroup">
  
  
  
  
  
    
  label="&Sample Action"
  
  icon="icons/sample.gif"
  
  class="colimas_plugin.actions.SampleAction"
  
  tooltip="Hello, Eclipse world"
  
  menubarPath="sampleMenu/sampleGroup"
  
  toolbarPath="sampleGroup"
  
  id="colimas_plugin.actions.SampleAction">
  
  
  
  
  
  
  
  2 建立调用Web Service类,该类实现调用Axis的WebService
  
  /*
  
  *
  
  Created on 2005/07/30
  
  *
  
  * TODO To change the template for this generated file go to
  
  * Window - Preferences - Java - Code Style - Code Templates
  
  */package com.nova.colimas.plugin.eclipse;
  
  import org.apache.axis.client.Call;
  
  import org.apache.axis.client.Service;
  
  import javax.xml.namespace.QName;import java.io.*;
  
  /**
  
  *@author tyrone
  
  *
  
  * TODO To change the template for this generated type comment go to
  
  * Window - Preferences - Java - Code Style - Code Templates
  
  */
  
  public class SendFileClient { private Call call;
  
  /**
  
  * The constrUCtor.
  
  */
  
  public SendFileClient() {
  
  try{
  
  Service service=
  
  new Service();
  
  call  = (Call) service.createCall();
  
  }catch(Exception ex){  System.out.println(ex.getMessage());
  
  } } public void saveFile(){ try {  String endpoint =  "http://localhost:8080/axis/services/DocumentFileManagement";
  
  System.out.println("start web service");
  
  call.setTargetEndpointAddress( new java.net.URL(endpoint) );
  
  call.setOperationName(new QName("http://soapinterop.org/", "saveFile"));
  
  File fp=new File("D:\\MyProject\\colimas\\colimas_plugin\\lib\\mail.jar");
  
  BufferedInputStream in=new BufferedInputStream(new FileInputStream(fp));
  
  int len=in.available();
  
  byte[] contents=new byte[len];
  
  in.read(contents,0,len);
  
  System.out.println("begin run");
  
  //开始调用Web Service:DocumentFileManagement的saveFile方法
  
  String ret = (String) call.invoke( new Object[] {fp.getName(),contents} );
  
  in.close();
  
  } catch (Exception e) {  System.err.println("error"+e.toString());
  
  }
  
  }
  
  }
  
  3 修改Action类的run方法
  
  Action类的run方法里的内容是Eclipse插件真正要做到事
  
  package colimas_plugin.actions;import org.eclipse.jface.action.IAction;
  
  import org.eclipse.jface.viewers.ISelection;
  
  import org.eclipse.ui.IWorkbenchWindow;import org.eclipse.ui.IWorkbenchWindowActionDelegate;
  
  import org.eclipse.jface.dialogs.MessageDialog;
  
  import com.nova.colimas.plugin.eclipse.*;
  
  /**
  
  * Our sample action implements workbench action delegate.
  
  * The action proxy will be created by the workbench and
  
  * shown in the UI. When the user tries to use the action,
  
  * this delegate will be created and execution will be
  
  * delegated to it. * @see IWorkbenchWindowActionDelegate
  
  */public class SampleAction implements IWorkbenchWindowActionDelegate { private IWorkbenchWindow window;
  
  /**
  
  * The constructor.
  
  */ public SampleAction() { }
  
  /**
  
  * The action has been activated. The argument of the
  
  * method represents the 'real' action sitting
  
  * in the workbench UI.
  
  * @see IWorkbenchWindowActionDelegate#run
  
  */ public void run(IAction action) { SendFileClient client=new SendFileClient();
  
  client.saveFile();
  
  MessageDialog.openInformation(  window.getShell(),
  
  "Colimas_plugin Plug-in",  "Colimas Connected");
  
  } /** * Selection in the workbench has been changed. We
  
  * can change the state of the 'real' action here
  
  * if we want, but this can only happen after
  
  * the delegate has been created.
  
  * @see IWorkbenchWindowActionDelegate#selectionChanged
  
  */ public void selectionChanged(IAction action, ISelection selection) { }
  
  /**
  
  * We can use this method to dispose of any system
  
  * resources we previously allocated.
  
  * @see IWorkbenchWindowActionDelegate#dispose
  
  */ public void dispose() { }
  
  /**
  
  * We will cache window object in order to
  
  * be able to provide parent shell for the message dialog.
  
  * @see IWorkbenchWindowActionDelegate#init
  
  */ public void init(IWorkbenchWindow window) { this.window = window;
  
  }
  
  4 调试
  
  首先启动Axis服务器,然后选择Eclipse的Run菜单的Run As -〉Run time workbench。
  
  这样会启动另一个Eclipse workbench,在这个workbench里你会看到toolbar里新增了一个按钮,
  
  点击按钮就会调用Webservice并返回控制台结果。
上一篇:教你学会XML Web Service 的基础 人气:604
下一篇:Axis 1.1 for Java进行Web Services开发 人气:900
浏览全部Java的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-10-10 企业网站智能管理系统(TZIMS) v6
2008-10-10 拓文asp.net网站内容管理系统 v6
2008-10-10 动网论坛PHP版 v2.0++ Build 081
2008-10-10 免费时代CMS v5.0
2008-10-10 wodig第四季中文DIGG社区 v4.1 b
2008-10-10 老Y文章管理系统 v2.2 bulid 081
2008-10-10 魔法盒动感相册 ASP+SQL版 v2.0
2008-10-10 Asoft签到管理系统 v3.0 Pack1
2008-10-10 哥特人音乐网潮流留言本 v1.1
2008-9-29 酷狗音乐(原KuGoo)2008 v5.310 正
2008-9-29 QQTab 1.1
2008-9-29 网络传送带 Net Transport 2.64a
2008-9-29 谷歌金山词霸v1.8
2008-9-29 TweakVI 1.0 Build 1090
2008-9-29 ACDSee Pro 2.5 Build 333 汉化绿
2008-9-29 Winamp v5.541(2189) 周明波简体
2008-9-27 CCleaner 2.12.651
2008-9-27 Mozilla Thunderbird 2.0.0.17 英
  发表评论
姓 名: 验证码:
内 容:
站长工具:网站收录查询 | Google PR查询 | ALEXA排名查询 | CSS在线编辑器 | 广告代码 | js/vbs加密 | md5加密 | 进制转换 | UTF-8 转换工具 | Html转换js | Html转换asp | Html转换php | Html转换perl
实用工具:汉字翻译拼音 | 拼音字典 | 符号对照表 | 个税计算 | 实时汇率查询换算 | 经典小工具 | 汉字简繁转换 | 普通单位换算 | 公制单位换算 | 生辰老黄历 | 国内电话区号 | 国家代码与域名缩写 | 文字加密解密 | 健康查询 | 万年历 | 汉字横竖排版 | 手机号码查询 | 计算器 | ip搜索
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号
ホームページ制作 不動産検索システム 求人情報
防水工事·改修工事 フットサル大会 探偵
SEO対策 中国語教室 ホームページ作成