Eclipse下使用Axis开发webservice
2010年01月21日
1. 将axis下的server-config.wsdd拷贝到myeclipse的web project的WEB-INF下。
2. 导入第三方包到工程下的lib目录
1.2. 设定servlet控制器修改WEB-INF下的web.xml文件,添加以下内容:
AxisServlet
org.apache.axis.transport.http.AxisServlet
SOAPMonitorService
org.apache.axis.monitor.SOAPMonitorService
SOAPMonitorPort
5001
100
AxisServlet
/servlet/AxisServlet
AxisServlet
*.jws
AxisServlet
/services/*
AxisServlet
/ws/*
SOAPMonitorService
/SOAPMonitor
wsdl
text/xml
xsd
text/xml
1.3. 添加要发布的服务添加要发布的服务到server-config.wsdd。如:
com.xxxxx.ws
1.4. 使用java2wsdl生成wsdl用axis的java2wsdl类来生成wsServerTest.wsdl:
选择项目,选择或者填入main函数org.apache.axis.wsdl.Java2WSDL
在run的程序参数设置为:
-o wsServerTest.wsdl
-l "http://localhost:8080/myproject/services/wsServerTest"
-n "urn:wsServerTest"
-p"com.xxxxx.ws.server" "urn:wsServerTest"
com.xxxxx.ws.server.ServerTestFacade
1.5. 使用wsdl2java生成stub用axis的wsdl2java来生成stub:
选择项目,选择或者填入main函数org.apache.axis.wsdl.WSDL2Java
在run的程序参数设置为:
D:\program\Eclipse3.2\wsSeverTest\wsServerTest.wsdl -t -p com.xxxxx.ws.client
1.6. 客户端测试如果是安全通道,将client.keystore和client.truststore放到wsClientTest工程下。在vm 参数设定:
-Djavax.net.ssl.keyStore=D:\program\Eclipse3.2\wsClientTest\client.keystore
-Djavax.net.ssl.keyStorePassword=changeit
-Djavax.net.ssl.trustStore=D:\program\Eclipse3.2\wsClientTest\client.truststore
将url改为https:localhost:8443/myproject/services/wsServerTest来调用发布的函数。
***********************************************************************
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并返回控制台结果。
9***************************************************************
发表评论
-
关于AdvancedDataGrid的header的数据传递
2012-01-20 10:18 623关于AdvancedDataGrid的header的数据传递 ... -
Flex AdvancedDataGrid表格过滤
2012-01-20 10:18 764Flex AdvancedDataGrid表格过滤 2010 ... -
Flex advanceddatagrid 验证处理
2012-01-20 10:18 727Flex advanceddatagrid 验证处理 201 ... -
3D场景的制作步骤
2012-01-20 10:18 8473D场景的制作步骤 2011 ... -
粤语翻译工具
2012-01-20 10:18 564粤语翻译工具 2011年04月14日 import j ... -
小学生作业规范批改要求
2012-01-19 15:19 1134小学生作业规范批改要求 2011年08月22日 亭湖区小 ... -
安卓新手成长日记之Andriod系统基础知识普及
2012-01-19 15:19 635安卓新手成长日记之Andriod系统基础知识普及 2011年 ... -
从零开始- Android刷机指南<一>
2012-01-19 15:19 878从零开始- Android刷机指南 2011年07月27日 ... -
接上一篇
2012-01-19 15:19 588接上一篇 2011年04月25日 第 2 章 路由器基 ... -
linux下服务说明<转>
2012-01-17 05:06 696linux下服务说明 2011年12月13日 我的Cen ... -
JAVA学习入门 对初次接触者 相当的有用
2012-01-17 05:06 642JAVA学习入门 对初次接 ... -
2011-3-26
2012-01-17 05:06 5612011-3-26 2011年03月26日 ... -
Unnamed System Edition v4.0
2012-01-17 05:06 741Unnamed System Edition v4.0 20 ... -
【 零 】 Java 随 笔 ( 2 月 9 日 更 新 ---- 贪 吃 蛇 雏 形 )
2012-01-16 03:57 705【 零 】 Java 随 笔 ( 2 月 9 日 更 新 -- ... -
javascript:history.go()和History.back()的区别
2012-01-16 03:57 1039javascript:history.go()和History ... -
com/sun/mail/util/LineInputStream
2012-01-16 03:57 797com/sun/mail/util/LineInputStre ... -
个人简历
2012-01-16 03:56 670个人简历 2011年02月17日 一、求职意向 应聘 ...
相关推荐
eclipse+AXIS开发webservice.doc
eclipse axis webservice 开发 eclipse下使用axis2 开发webservice系统
Eclipse中使用Axis2开发Webservice过程详细教程,包括解决Eclipse无法使用Axis2插件的问题解决方法,亲测可用
eclipse+AXIS开发webservice.pdfeclipse+AXIS开发webservice.pdfeclipse+AXIS开发webservice.pdfeclipse+AXIS开发webservice.pdfeclipse+AXIS开发webservice.pdf
Eclipse + Axis2发布WebService
Eclipse用Axis框架开发WebService
用eclipse或者myeclipse的axis插件开发webservice 服务端的例子程序,短小精悍,很精典!
用eclipse+xdoclet+axis开发WebService.pdf
从架构师的角度来理解:webservice是一个软件系统,为了支持跨网络的机器间相互操作交互而设计。Web Service服务通常被定义为一组模块化的API,它们可以通过网络进行调用,来执行远程系统的请求服务。
Eclipse 开发 Axis_WebService 实例总结
在eclipse下用tomcat服务器和axis插件创建WebService服务,doc文档
Axis2与Eclipse整合开发的Web Service的服务端
eclipse+axis2学习webservice实例,亲测!
在eclipse上使用axis2编辑webservice和发布webservice
部署WebService(eclipse-axis2)部署WebService(eclipse-axis2)部署WebService(eclipse-axis2)部署WebService(eclipse-axis2)部署WebService(eclipse-axis2)
资源包含了:axis2-1.7.4-bin.zip、axis2-1.7.4-war.zip、axis2-eclipse-...备注:资源超过了70M 分成了3部分 见axis2方式开发webservice(一)和 axis2方式开发webservice(二)、 axis2方式开发webservice(三)
eclipse使用axis1.4发布联通vac的webservice服务代码,并有客户端测试
eclipse+tomcat+axis2创建webservice
利用eclipse,axis2框架,搭建WebService服务端,以及如何调用接口的教程