一 .准备:
1. 首先下载axis2-1.6.2 需要axis2-1.6.2-bin.zip ,axis2-1.6.2-war.zip 文件 。 下载地址http://axis.apache.org/axis2/java/core/download.cgi
2. 解压下载的war 包,并将内部的war包在tomcat下发布,测试是否成功 http://localhost:8080/axis2/ 点击Service会进入Service列表页面,
当前只有一个Version服务。http://localhost:8080/axis2/services/Version?wsdl
3. 下载 axis2-eclipse-service-plugin-1.6.2.zip,axis2-eclipse-codegen-plugin-1.6.2.zip 解压后将plugins 复制到eclipse的plugins,
高版本的eclipse需要复制到dropins 文件夹下 下载地址 http://axis.apache.org/axis2/java/core/tools/index.html
myeclipse 8.5 会报缺少jar 的错误,网上找到需要的jar ,放在dropins 文件夹下,并删除configuration 下的update文件夹
二 .部署
1. 新建java web project 工程,并将 axis2 的war包中的 lib 中的文件 ,jar包 拷贝到项目的lib中 ,并加入引用
将 axis2的war包中的WEB-INF 下 conf 内容 复制到 项目 WEB-INF 中的conf 下
将 axis2 的war包中的 WEB-INF 下 modules 文件夹复制到 项目 WEB-INF 中的 modules 下
<servlet>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
3. 新增 com.webservice.WebserviceTest.java,
public String showName(String name) {
System.out.println(new SimpleDateFormat("yyyyMMddHHmmssSSS") .format(new Date())+"service showname");
return "hello"+name;
}
4. 新增 WEB-INF\services 文件夹,并创建\AxisService\meta-inf\services.xml 内容如下
<service name="AxisService"> <description>AxisService</description> <parameter name="ServiceClass">com.webservice.WebserviceTest</parameter> <operation name="showName"> <messageReceiver class="org.apache.axis2.rpc.receivers.RPcmessageReceiver" /> </operation> </service>
5.启动tomcat,http://localhost:8080/项目名称/services/AxisService?wsdl 测试
三 .调用
在eclipse 中,选择 new ---- other ---- Axis2 Code Generator,点击next
勾选Generate Java source code from a WSDL file,点击Next;
输入 服务路径 http://localhost:8080/项目名称/services/AxisService?wsdl 点击next
若 输入服务路径错误或服务未启动则出现
继续next ,出现
提示:All operations completed successfully! 生成成功。
2. 新建java 项目 ,并 将 bin.zip中的 lib 下的所有jar 包复制到 项目下的lib 包中,并加入引用
4. 创建 test.TestWs.java,
public class TestWs { public static void main(String[] args) throws remoteexception { AxisServiceStub stub = new AxisServiceStub(); //传递AxisServiceStub.ShowName对象,相关参数在这边赋值。 ShowName command = new ShowName(); command.setName("Hello!"); //取得返回值 String name = stub.showName(command).get_return(); System.out.println(new SimpleDateFormat("yyyyMMddHHmmssSSS") .format(new Date())); System.out.println(name+"method showname"); } }
下来测试,就行
http://download.csdn.net/detail/meililiuwei/5454911 上传的资源中有所有需要的jar包
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。