- 浏览: 47421 次
- 性别:
- 来自: 重庆
文章分类
最新评论
部署WebService(Axis2和spring集成)
spring集成Axis2
server 实现
步骤一 创建Web工程
步骤二 下载Axis2二进制包(地址:http://axis.apache.org/axis2/java/core/download.cgi)
步骤三 将Axis2包加载到创建的Web工程(将Axis->lib文件夹下的jar包复制到Web工程->WebRoot->WEB-INF->lib文件夹下(还需要加上spring的核心包))
activation-1.1.jar
axiom-api-1.2.12.jar
axiom-impl-1.2.12.jar
axis2-adb-1.6.1.jar
axis2-adb-codegen-1.6.1.jar
axis2-java2wsdl-1.6.1.jar
axis2-kernel-1.6.1.jar
axis2-spring-1.5.jar
axis2-transport-http-1.6.1.jar
axis2-transport-local-1.6.1.jar
commons-codec-1.3.jar
commons-httpclient-3.1.jar
commons-logging-1.1.1.jar
dom4j-1.6.1.jar
geronimo-stax-api_1.0_spec-1.0.1.jar
httpcore-4.0.jar
mail-1.4.jar
neethi-3.0.1.jar
spring.jar
woden-api-1.0M8.jar
wsdl4j-1.6.2.jar
wstx-asl-3.2.9.jar
XmlSchema-1.4.7.jar
步骤四 在Web工程下创建一个接口并定义一个方法
例:
package com.soap.axis2;
public interface IServiceServer
{
public String sayhello(String name);
}
步骤五 新建一个类继承接口
例:
package com.soap.axis2;
public class ServiceServerImpl implements IServiceServer
{
@Override
public String sayhello(String name)
{
return "my name is "+name;
}
}
步骤六 在工程src目录下创建spring配置文件applicationContext.xml
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="SayHelloService" class="com.soap.axis2.ServiceServerImpl">
</bean>
</beans>
步骤七 在Web工程->WebRoot目录下新建axis2-web -> listServices.jsp目录和文件
listServices.jsp文件内容如下:
<%@
page contentType="text/html;charset=UTF-8" language="java"
%><%@
page import="org.apache.axis2.Constants,
org.apache.axis2.description.AxisOperation,
org.apache.axis2.description.AxisService,
java.util.Collection,
java.util.HashMap,
java.util.Iterator"
%><html>
<head><title>List Services</title>
<style>
h2{margin:20 0 5 0;}
ul{margin-top:5;}
</style>
</head>
<body>
<h1>Available services</h1>
<%
HashMap serviceMap = (HashMap) request.getSession().getAttribute(Constants.SERVICE_MAP);
Collection servicecol = serviceMap.values();
if(servicecol.size()==0){%>Available services is Empty.<%}
for (Iterator iterator = servicecol.iterator(); iterator.hasNext();) {
AxisService axisService = (AxisService) iterator.next();
Iterator opItr = axisService.getOperations();
String serviceName = axisService.getName();
%>
<h2><font color="blue"><a href="<%=serviceName %>?wsdl" target="_blank"><%=serviceName%></a></font></h2>
<i>Available Operations</i>
<ul>
<%
while (opItr.hasNext()) {
AxisOperation axisOperation = (AxisOperation) opItr.next();
%><li><%=axisOperation.getName().getLocalPart()%></li><%
}
%>
</ul>
<%
}
%>
</body>
</html>
步骤八 在Web工程->WebRoot->WEB-INF下新建services->service(这个目录自定义)->META-INF->services.xml目录和文件
services.xml文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<serviceGroup>
<service name="sayHelloService">
<description>
sayHelloService:Spring POJO Axis2 Service Sample
</description>
<parameter name="ServiceClass">
com.soap.axis2.IServiceServer
</parameter>
<parameter name="ServiceObjectSupplier">
org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
</parameter>
<parameter name="SpringBeanName">SayHelloService</parameter>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</messageReceivers>
<operation name="sayHello">
<messageReceiver
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>
</serviceGroup>
步骤九 修改Web工程->WebRoot->WEB-INF->web.xml
在web.xml文件<web-app></web-app>中加上:
<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>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
发布我们新建的Web工程
打开浏览器访问:http://localhost:8080/WebService//services/listServices
会出现我们部署的服务 sayHelloService
client 实现
步骤一 在工程中新建一个类(可以重新建一个工程但需要导入Axis2的相关包)
例:
package com.soap.axis2.client;
import javax.xml.namespace.QName;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
public class ServiceClient
{
public static void main(String[] args1) throws AxisFault
{
String path = "http://localhost:8080/WebService/services/sayHelloService";
EndpointReference targetEPR = new EndpointReference(path);
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
options.setTo(targetEPR);
QName opGetWeather = new QName("http://axis2.soap.com","sayhello");
Object[] response = serviceClient.invokeBlocking(opGetWeather,
new Object[]{"zhangsan"},new Class[]{String.class});
System.out.println(response[0]);
}
}
执行此类
spring集成Axis2
server 实现
步骤一 创建Web工程
步骤二 下载Axis2二进制包(地址:http://axis.apache.org/axis2/java/core/download.cgi)
步骤三 将Axis2包加载到创建的Web工程(将Axis->lib文件夹下的jar包复制到Web工程->WebRoot->WEB-INF->lib文件夹下(还需要加上spring的核心包))
activation-1.1.jar
axiom-api-1.2.12.jar
axiom-impl-1.2.12.jar
axis2-adb-1.6.1.jar
axis2-adb-codegen-1.6.1.jar
axis2-java2wsdl-1.6.1.jar
axis2-kernel-1.6.1.jar
axis2-spring-1.5.jar
axis2-transport-http-1.6.1.jar
axis2-transport-local-1.6.1.jar
commons-codec-1.3.jar
commons-httpclient-3.1.jar
commons-logging-1.1.1.jar
dom4j-1.6.1.jar
geronimo-stax-api_1.0_spec-1.0.1.jar
httpcore-4.0.jar
mail-1.4.jar
neethi-3.0.1.jar
spring.jar
woden-api-1.0M8.jar
wsdl4j-1.6.2.jar
wstx-asl-3.2.9.jar
XmlSchema-1.4.7.jar
步骤四 在Web工程下创建一个接口并定义一个方法
例:
package com.soap.axis2;
public interface IServiceServer
{
public String sayhello(String name);
}
步骤五 新建一个类继承接口
例:
package com.soap.axis2;
public class ServiceServerImpl implements IServiceServer
{
@Override
public String sayhello(String name)
{
return "my name is "+name;
}
}
步骤六 在工程src目录下创建spring配置文件applicationContext.xml
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="SayHelloService" class="com.soap.axis2.ServiceServerImpl">
</bean>
</beans>
步骤七 在Web工程->WebRoot目录下新建axis2-web -> listServices.jsp目录和文件
listServices.jsp文件内容如下:
<%@
page contentType="text/html;charset=UTF-8" language="java"
%><%@
page import="org.apache.axis2.Constants,
org.apache.axis2.description.AxisOperation,
org.apache.axis2.description.AxisService,
java.util.Collection,
java.util.HashMap,
java.util.Iterator"
%><html>
<head><title>List Services</title>
<style>
h2{margin:20 0 5 0;}
ul{margin-top:5;}
</style>
</head>
<body>
<h1>Available services</h1>
<%
HashMap serviceMap = (HashMap) request.getSession().getAttribute(Constants.SERVICE_MAP);
Collection servicecol = serviceMap.values();
if(servicecol.size()==0){%>Available services is Empty.<%}
for (Iterator iterator = servicecol.iterator(); iterator.hasNext();) {
AxisService axisService = (AxisService) iterator.next();
Iterator opItr = axisService.getOperations();
String serviceName = axisService.getName();
%>
<h2><font color="blue"><a href="<%=serviceName %>?wsdl" target="_blank"><%=serviceName%></a></font></h2>
<i>Available Operations</i>
<ul>
<%
while (opItr.hasNext()) {
AxisOperation axisOperation = (AxisOperation) opItr.next();
%><li><%=axisOperation.getName().getLocalPart()%></li><%
}
%>
</ul>
<%
}
%>
</body>
</html>
步骤八 在Web工程->WebRoot->WEB-INF下新建services->service(这个目录自定义)->META-INF->services.xml目录和文件
services.xml文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<serviceGroup>
<service name="sayHelloService">
<description>
sayHelloService:Spring POJO Axis2 Service Sample
</description>
<parameter name="ServiceClass">
com.soap.axis2.IServiceServer
</parameter>
<parameter name="ServiceObjectSupplier">
org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
</parameter>
<parameter name="SpringBeanName">SayHelloService</parameter>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</messageReceivers>
<operation name="sayHello">
<messageReceiver
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>
</serviceGroup>
步骤九 修改Web工程->WebRoot->WEB-INF->web.xml
在web.xml文件<web-app></web-app>中加上:
<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>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
发布我们新建的Web工程
打开浏览器访问:http://localhost:8080/WebService//services/listServices
会出现我们部署的服务 sayHelloService
client 实现
步骤一 在工程中新建一个类(可以重新建一个工程但需要导入Axis2的相关包)
例:
package com.soap.axis2.client;
import javax.xml.namespace.QName;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
public class ServiceClient
{
public static void main(String[] args1) throws AxisFault
{
String path = "http://localhost:8080/WebService/services/sayHelloService";
EndpointReference targetEPR = new EndpointReference(path);
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
options.setTo(targetEPR);
QName opGetWeather = new QName("http://axis2.soap.com","sayhello");
Object[] response = serviceClient.invokeBlocking(opGetWeather,
new Object[]{"zhangsan"},new Class[]{String.class});
System.out.println(response[0]);
}
}
执行此类
- WebService_spring_axis2_.rar (6.8 MB)
- 下载次数: 226
发表评论
-
jxl操作execl
2014-06-12 16:18 558jxl操作execljxl操作execljxl操作execlj ... -
jFreechart
2013-03-08 16:15 0jFreechart -
需要学习内容
2013-03-05 22:15 0技术问题: 1、spring框架的实现原理(ioc、aop ... -
JAVA NIO
2012-10-27 09:51 0JAVA NIO -
JAVA类加载
2012-10-26 16:06 0JAVA类加载 -
理解JVM
2012-10-26 16:06 0理解JVM -
理解HashMap,HashTable
2012-10-26 16:05 0理解HashMap,HashTable -
JMS ActiveMQ
2012-10-26 16:04 0JMS和WebService的区别? 1.WebService ... -
JAVA垃圾收集机制
2012-10-26 16:01 0... -
JAVA并发编程学习
2012-10-26 16:00 0java并发编程 -
ssh的优缺点整理
2012-09-22 16:13 0以前开发web应用程序的 ... -
java 复习
2012-09-12 14:31 0java的堆与栈 堆: 1、堆是一个运行时数据区,有new.. ... -
javascript实现图片预览
2012-07-31 15:22 0使用两种不同的方法实现图片预览功能 Java代码 &l ... -
使用JSONP完成HTTPS跨域请求
2012-04-02 21:26 26278使用JSONP完成HTTPS跨域请 ... -
部署WebService服务(cxf,spring)2
2012-03-29 18:30 0client 实现 步骤一 在工程中新建一个类(可以重新 ... -
部署WebService服务(cxf,spring)
2012-03-30 18:11 5212使用CXF,spring部署Web Service服务 se ... -
部署WebService服务(Axis2,spring)2
2012-03-27 11:06 0步骤七 在Web工程->WebRoot目录下新建axis ... -
部署WebService服务(Axis)
2012-03-24 16:44 1363Axis实现Axis server实现步骤一 创建Web工程 ...
相关推荐
简单例子:axis2整合spring发布webservice,以及session的管理
部署WebService(eclipse-axis2)部署WebService(eclipse-axis2)部署WebService(eclipse-axis2)部署WebService(eclipse-axis2)部署WebService(eclipse-axis2)
webService—Axis实例webService—Axis实例webService—Axis实例webService—Axis实例webService—Axis实例webService—Axis实例webService—Axis实例
本案例实现使用Axis2生成.arr包发布WebService服务,并使用Axis2生成客户端代码方式调用WebService
axis2例子 webservice axis2 示例axis2例子 webservice axis2 示例axis2例子 webservice axis2 示例axis2例子 webservice axis2 示例axis2例子 webservice axis2 示例
借鉴网上的资源,弄了一个SpringBoot开发WebService之Axis示例。
一个可能直接在tomcat运行的webservice例子(Axis+Spring+jpa)
在网上找了很久的资料,接口已经跟客户对接,特编写了代码文档和附带jar包,并含其他网站的参考地址,注意jdk环境要1.6或以上版本
axis2+Spring提供WebService服务,有调用方法类。
Axis2WebService与Spring的整合
手写的axis2案例,包括服务端与客户端WebService_client、WebService_server,详细在我的博客中有记录,需要的可以自行下载
使用Axis2部署WebService,这是我的一点学习 笔记, 仅供初学者了解用,呵呵呵 不需要资源分的
NULL 博文链接:https://wujianjun.iteye.com/blog/517152
axis发布webservice教程axis发布webservice教程axis发布webservice教程axis发布webservice教程
webservice新手axis2超详细教程
WebService Axis2 经典教程 Web Service是现在最适合实现SOA的技术,而Axis2是实现Web Service的一种技术框架(架构
Axis WebService。Axis WebService。Axis WebService。Axis WebService。
Axis的简单准备 Axis的入门实例 Axis复杂对象类型的WebService ...Axis用Spring的JavaBean发布WebService Axis异步调用WebService Axis 的Module模块 Axis使用SoapMonitar监视WebService的请求和响应信息
下载到你指定的路径,解开压缩包后,在文件夹下直接打开 01.html 文件即可,内容非常详细,并且所有代码均能过。