<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Terry.Li-彬

    虛其心,可解天下之問;專其心,可治天下之學;靜其心,可悟天下之理;恒其心,可成天下之業。

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      143 隨筆 :: 344 文章 :: 130 評論 :: 0 Trackbacks
    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并返回控制臺結果。
    posted on 2007-09-11 10:12 禮物 閱讀(1682) 評論(0)  編輯  收藏 所屬分類: web service
    主站蜘蛛池模板: 亚洲国产精品国自产拍AV| 免费人成在线观看网站| 亚洲欧洲日韩在线电影| 自拍偷自拍亚洲精品被多人伦好爽| 91免费精品国自产拍在线不卡| 日韩电影免费观看| 中文字幕在线免费播放| 日韩成人毛片高清视频免费看| 亚洲乱亚洲乱妇无码| 亚洲人成免费电影| 亚洲精品亚洲人成在线麻豆| 亚洲国产精品无码一线岛国| 久久久久久A亚洲欧洲AV冫| 国产gav成人免费播放视频| 老司机在线免费视频| 97在线视频免费播放| 污视频在线免费观看| 国产精品免费看久久久| 99视频在线免费观看| 中国一级毛片免费看视频| 九九久久国产精品免费热6| 免费观看又污又黄在线观看| 美女18毛片免费视频| 精品在线视频免费| 国产成人综合久久精品亚洲| 久久精品国产亚洲av瑜伽| 亚洲欧美日韩国产成人| 亚洲色偷精品一区二区三区| 日韩亚洲国产高清免费视频| 国产精品亚洲片夜色在线 | 中文字幕免费在线观看动作大片| 免费一级全黄少妇性色生活片| 美女视频黄a视频全免费网站一区 美女视频黄a视频全免费网站色 | 亚洲中文字幕无码久久精品1| 亚洲精品无码专区久久同性男| 免费少妇a级毛片人成网| 亚洲成?v人片天堂网无码| 亚洲精品无码久久不卡| 中文字幕亚洲一区二区va在线| 亚洲午夜国产精品无码老牛影视| 亚洲夜夜欢A∨一区二区三区|