WebService学习之旅(五)基于Apache Axis2发布第一个WebService
来源:互联网 发布:mac excel怎么加 编辑:程序博客网 时间:2024/05/29 13:49
上篇博文介绍了如何將axis2 webservice引擎安装到Web容器中,本节开始介绍如何基于apache axis2发布第一个简单的WebService。
一、WebService服务端发布步骤
1.打开Eclipse工程,新建一个Java Project,例如笔者工程名为axis2-recipe01。
2.编写Web服务接口及实现类
HelloWorld.java
package com.csdn.ws.axis2.recipe01;public interface HelloWorld { String sayHello(String name);}
HelloWorldImpl.java
package com.csdn.ws.axis2.recipe01;public class HelloWorldImpl implements HelloWorld { @Override public String sayHello(String name) { return "hello," + name; }}
大家可能已经注意到了,前面我们使用jax-ws发布webservice时,web服务接口和实现类需要使用注解@WebService和@WebMethod修饰,但是使用axis2引擎时并不需要。
2.在工程根路径下,新建一个META-INF目录,然后在该目录下新建一个services.xml文件,注意名称不能改变。
3.打开services.xml,添加webservice的描述信息,内容如下:
<?xml version="1.0" encoding="UTF-8"?><service name="HelloWorld"> <description> HelloWorld Service Example </description> <parameter name="ServiceClass"> com.csdn.ws.axis2.recipe01.HelloWorldImpl </parameter> <parameter name="useOriginalwsdl"> false </parameter> <operation name="sayHello"> <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> </operation></service>
根节点为service,它的name属性指定webservice名称,parameter标签用于指定一些配置参数,上面的ServiceClass参数指定webservice接口,useOriginalwsdl参数指定是否使用axis2自动生成wsdl,该参数通常为false,表示由axis2自动生成wsdl。operation标签指定对外发布的方法名。
4.在工程上点击右键=>export=>Jar File,点击Next按钮,去掉.classpath和.project文件选择。
5.保存文件名为axis2-recipe01.aar,將此文件复制到%TOMCAT_HOME%/webapps/axis2/WEB-INF/services目录下。
(注:axis2安装到tomcat请参考前面的文章)
6.重启tomcat服务器,打开浏览器访问http://localhost:8080/axis2/axis2-web/index.jsp
然后点击Services链接,看到如下界面说明我们的WebService发布成功。
点击HelloWorld链接,可以查看该WebService的wsdl文档。
本节内容就到此为止吧,基于axis2的客户端调用放在下节介绍。
- WebService学习之旅(五)基于Apache Axis2发布第一个WebService
- WebService学习之旅(四)Apache Axis2的安装
- WebService学习之旅(七)Axis2发布WebService的几种方式
- WebService学习之旅(六)使用Apache Axis2实现WebService客户端调用
- 发布第一个WebService
- WebService学习之Axis2
- WebService学习之旅(二)JAX-WS基于Web容器发布WebService
- 应用Apache Axis2 实现Webservice发布
- 应用Apache Axis2 实现Webservice发布
- 应用Apache Axis2 实现Webservice发布
- Android逗比自学webservice(五)第一个webservice
- webservice发布第一个服务
- Delphi动态调用Java的WebService —— 基于“Axis2发布WebService例子(HelloWorld)”
- AXIS2:如何发布webservice
- AXIS2发布WebService
- [转载] AXIS2发布WebService
- axis2发布WebService工程
- Axis2发布WebService
- Android 应用界面开发笔记 Service
- 嵌入式Linux实现TCP/IP通信
- 一步步点亮LED4_使用位运算实现复杂点亮要求
- 用Java写解谜Rpg-1.我理解的MVC与课设
- Codeforces 474 D Flowers(DP)
- WebService学习之旅(五)基于Apache Axis2发布第一个WebService
- jQuery 事件中stoppropagation和stopimmediatepropagation的区别
- Java中对象的引用传值
- Intent和PendingIntent的区别
- PAT 浙大数据结构(Reversing Linked List)
- Educational Codeforces Round 10 D Nested Segments
- Rest使用
- windows计算程序运行时间
- 安卓中WebView内存泄漏等问题