Tutorials to .com

Tutorials to .com » Jsp » Xml » Eclipse plug-ins to achieve Axis WebService client

Eclipse plug-ins to achieve Axis WebService client

Print View , by: iSee ,Total views: 13 ,Word Count: 1235 ,Date: Mon, 20 Apr 2009 Time: 3:39 AM


1 establishment of Eclipse plug-in File-> New-> Project-> Plug-in development of Plug-in project-> Next, fill out the project name, Next, fill in the content, Next, select Create plug-in using one of the templates, select Hello, World, Finish.

View can be seen in the plugin.xml, in Run in with the required Web Service call jar package. Reads as follows:






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 the establishment of call Web Service class, such realization of the WebService call Axis

/ *

*

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");

/ / The beginning of calling Web Service: DocumentFileManagement method saveFile of String ret = (String) call.invoke (new Object [] (fp.getName (), contents));

in.close ();

) Catch (Exception e) (System.err.println ( "error" + e.toString ());

)

)

)

3 modified the run methods of Class Action Class Action in the run method is the Eclipse plug-ins to do things the real 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 debug <br> <br> start Axis server, and then select Eclipse's Run menu Run As -> Run time workbench.

This will start another Eclipse workbench, in the workbench where you will see a toolbar button to add,

Click on the button will call Webservice and return to console the results.


Java and XML Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.