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 ...
随机推荐
- Google Map API 学习三
- Xamarin最新crack 包含IOS
Xamarin.Android 4.10.01068 & Xamarin.iOS 1.8.361 28 Comments tweet inShare NEW support f ...
- HDU-4089 Activation
http://acm.hdu.edu.cn/showproblem.php?pid=4089 Activation Time Limit: 20000/10000 MS (Java/Others) ...
- Matlab与CCS的连接
1.CCS概述 Matlab 6.5(R13)或以上集成了CCSLink工具,可以支持CCS能够识别的任何板卡及其硬件DSP. 验证CCSLink是否在主机上安装成功,Matlab输入命令:help ...
- HDOJ/HDU 2561 第二小整数(水题~排序~)
Problem Description 求n个整数中倒数第二小的数. 每一个整数都独立看成一个数,比如,有三个数分别是1,1,3,那么,第二小的数就是1. Input 输入包含多组测试数据. 输入的第 ...
- HTML-通过点击网页上的文字弹出QQ添加好友页面
在网上参考了部分方法,综合了一下. 发现有2中方式: 第一种是不能直接弹出添加界面的,只能弹出网页,再通过网页中的添加好友才能添加: 弹出的网页是这样的(我是写成在新的网页中打开) 现在看实现的代码: ...
- 乐视手机1S正式发售,乐视商城官网抽风遭网友吐槽
乐视手机1S正式发售,乐视商城官网抽风遭网友吐槽 10月27日,乐视召开的新品发布会上正式推出千元金属新机乐1s,售价1099元.今天11月3日上午10:00,乐1s在乐视商城.京东商城首发开卖,现货 ...
- (转载)绿色版Mysql的安装配置
本文出自于:http://johnnyhg.javaeye.com/blog/245544 一.下载MySQL http://www.mysql.org/downloads 我下载的是mysql-no ...
- 2014年河南省第七届ACM大赛总结
虽然大赛已经结束了两天,不过比赛的场景还是不断地在眼前回放,一遍遍,这次的比赛给了我很深刻的感悟还有教训. 刚开始比赛选择了贩卖武器那道题,也是全场到最后唯一没有被人做出来的一道题,策略的严重错误,大 ...
- UVA 10106 (13.08.02)
Product The Problem The problem is to multiply two integers X, Y. (0<=X,Y<10250) The Input T ...