spring与axis2整合发布webservice
最近在研究整合spring框架和axis2发布webservice服务,由于本人也才学java不久,为了便于以后的查看,在这里记录下发布过程。
所需的工具包,spring.jar和axis2链接地址为http://pan.baidu.com/s/1gdgVBoB,这里发布服务只需要两个包,spring-framework-3.2.1.RELEASE-dist.zip和axis2-1.6.2-war.zip。首先解压axis2-1.6.2-war.zip,得到axis2.war文件,放入tomcat的webapps目录中,启动tomcat,浏览器中输入http://ip:端口号/axis2/出现

说明axis2运行成功,会在webapps中生成一个叫axis2的目录。接着在myeclipse中新建一个web工程,这里我取名为WjWebservice,工程目录结构

解压上面的两个包,将其中的jar包全部放入WebRoot/WEB-INF/lib目录中,在WEB-INF目录下新建conf和modules目录,将tomcat的webapps/axis2/WEB-INF下的conf和modules目录中的文件分别倒入在web工程中新建的conf和modules下。新建services目录,新建test(这个目录名字可以自己随便取)目录,新建META-INF目录,新建services.xml。
在com.wj.service中新建HelloWorld接口,代码为:
package com.wj.service;
public interface HelloWorld {
public String greeting(String name);
public void print();
}
在com.wj.service中新建HelloWorldImpl类实现HelloWorld接口,代码为:
package com.wj.service;
public class HelloWorldImpl implements HelloWorld{
public String greeting(String name) {
return name+"hello world!";
}
public void print() {
System.out.println("Hi!");
}
}
在com.wj.service中新建webservice javabean对象HelloWorldService类,代码为:
package com.wj.service;
public class HelloWorldService {
public HelloWorld helloWorld;
public HelloWorld getHelloWorld() {
return helloWorld;
}
public void setHelloWorld(HelloWorld helloWorld) {
this.helloWorld = helloWorld;
}
public String sayGreeting(String name)
{
return helloWorld.greeting(name);
}
public void sayPrint()
{
helloWorld.print();
}
}
配置spring的applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> <bean id= "applicationContext" class = "org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" />
<bean id="helloWorldImpl" class="com.wj.service.HelloWorldImpl">
</bean>
<bean id="helloWorldService" class="com.wj.service.HelloWorldService">
<property name="helloWorld" ref="helloWorldImpl"></property>
</bean>
</beans>
配置web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 注册axis2的servlet -->
<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>
<!-- 加载spring的配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- 增加spring监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
配置services.xml:
<?xml version="1.0" encoding="UTF-8"?>
<service name= "helloWorldWebservice" targetNamespace="http://www.wujianjun.org">
<description>simple spring example</description>
<parameter name= "ServiceObjectSupplier" >
org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier
</parameter>
<parameter name= "SpringBeanName" >helloWorldService</parameter>
<messageReceivers>
<messageReceiver mep= "http://www.w3.org/2004/08/wsdl/in-only"
class = "org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
<messageReceiver mep= "http://www.w3.org/2004/08/wsdl/in-out"
class = "org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
</service>
浏览器中输入:http://IP:端口/工程名/services/services.xml配置的服务名称?wsdl生成wsdl文件

到此webservice服务发布完成。
spring与axis2整合发布webservice的更多相关文章
- WebService学习之旅(三)JAX-WS与Spring整合发布WebService
Spring本身就提供了对JAX-WS的支持,有兴趣的读者可以研究下Spring的Spring-WS项目,项目地址: http://docs.spring.io/spring-ws/sites/1.5 ...
- 使用Axis2方式发布webService实例说明
1.简单的pojo方式: 不需要写配置文件,直接把class文件拷贝到axis2的WEB-INF目录下的poji文件夹下即可.但其局限性表现在,实现类不能有包声明,这在实际开发过程中使用较少,这里不做 ...
- spring与cxf整合配置webservice接口(以jaxws:server的方式配置)
ps:最近项目需要跟其他系统做同步,需要使用webservice来提供接口给其他系统调用:临时抱佛脚赶紧去网上找了下资料,发现用Endpoint的方式发布接口好容易哦:赶紧写了个例子做验证,发布成功. ...
- 使用Axis2方式发布webService的三种方式
1.Axis2的下载和安装 首先可以下载如下两个zip包:axis2-1.6.1-bin.zipaxis2-1.6.1-war.zip其中 axis2-1.6.1-bin.zip文件中包含了Axis2 ...
- 13_CXF和Spring整合发布服务
[服务端] 第一步:建立一个Web项目 第二步:填充CXF jar包 第三步:创建接口及服务类 [工程截图(对比之前的WebService_CXF_Server00)] [applicationCon ...
- 使用JDK和axis2发布webservice
最近使用webservice进行远程调用一直很火,自从JDK1.6版本发布后,发布一个webservice项目变得更加简单了 笔者由于工作的需要针对JDK和axis2如何发布webservice做过相 ...
- 使用CXF发布WebService服务简单实例
一.说明: 前面介绍了使用axis2来发布Webservice服务,现在介绍一种更popular,更高效的Webservice服务发布技术:CXF Apache CXF = Celtix + XFir ...
- Spring整合CXF之发布WebService服务
今天我们来讲下如何用Spring来整合CXF,来发布WebService服务: 给下官方文档地址:http://cxf.apache.org/docs/writing-a-service-with-s ...
- Spring+CXF整合来管理webservice(服务器启动发布webservice)
Spring+CXF整合来管理webservice 实现步骤: 1. 添加cxf.jar 包(集成了Spring.jar.servlet.jar ),spring.jar包 ,serv ...
随机推荐
- 在html页面中利用ftp访问协议格式载入服务器图片
访问格式为:ftp://用户名:密码@服务器ip:服务器端口/具体文件路径 如下所示: <img src="ftp://lxj:123@127.0.0.1:21/IMG_2013051 ...
- (转载)获取当前运行的PHP版本信息
(转载)http://www.clovery.org/get-the-php-version-information.html 获取PHP运行环境信息,可以使用下面的函数. <?php phpi ...
- 万能的Volley
v1olley能干那些事?发送get请求 public void getJson() { String url = "http://"+host+":8080/web/j ...
- 判断iis是否已经安装
判断iis是否已经安装? 访问http://127.0.0.1 能得到正确页面的是已经安装. 活者查看控制面板-添加删除程序-windows组件-internet信息服务(IIS)前面的没有打勾则没有 ...
- C++中new和malloc
1.malloc的工作原理: malloc使用一个数据结构(链表)来维护分配空间链表的构成:分配的空间/上一个空间的数据/下一个空间/空间大小等信息. 对malloc分配的空间不要越界访问,因为 ...
- 【转】OpenGL基础图形编程(一)
原文:http://blog.chinaunix.net/uid-20638550-id-1909183.html 分类: 一.OpenGL与3D图形世界 1.1.OpenGL使人们进入三维图形世界 ...
- (转载)关于having 1=1 和group by 爆表的思考和总结
上次在网上看到一篇关于having 1=1 和group by 爆表注射的文章,看得我晕乎乎的,为了了解其根本原理,我稍微学习了下数据库知识,翻了下资料,但有些资料找不到,于是,开始发挥本天才的思维来 ...
- 2015/11/06 社保查询系统持续 挂机ing
- 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(20)-权限管理系统-根据权限获取菜单
原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(20)-权限管理系统-根据权限获取菜单 不知不觉到20讲,真是漫长的日子,可惜最近工作挺忙,要不可以有更多 ...
- BloomFilter--大规模数据处理利器
Bloom Filter是由Bloom在1970年提出的一种多哈希函数映射的快速查找算法.通常应用在一些需要快速判断某个元素是否属于集合,但是并不严格要求100%正确的场合. 一. 实例 为了说明Bl ...