- 浏览: 485052 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (301)
- Swing技术 (1)
- Linux (1)
- Javascript (22)
- 数据结构和算法 (3)
- J2SE (36)
- workflow (5)
- 设计模式 (14)
- web service (19)
- Ajax (14)
- 中间件 & 服务器 (8)
- 多线程 (9)
- Oracle (52)
- sys & soft (10)
- JMS (3)
- sso (9)
- android (11)
- struts2 (10)
- web协议 (2)
- 分布式 (2)
- PM (2)
- OLAP (3)
- Redis (2)
- Hibernate (7)
- ibatis (2)
- SQLServer (1)
- maven (3)
- Spring (7)
- Jsp (2)
- slf4j (1)
- jQuery (15)
- 权限 (1)
- 系统集成 (1)
- 笔记 (1)
- Freemarker (2)
- 项目管理 (1)
- eclipse (3)
- GIS (1)
- NoSql (3)
- win10 (1)
- win10网络 (2)
- 底层 (3)
- 数据库 (0)
最新评论
-
kabuto_v:
请问那种图,uml图是怎么画出来的呢?是您自己手工画的,还是有 ...
FastJSON 序列化、反序列化实现 -
梦行Monxin商城系统:
电商实例、业务并发、网站并发及解决方法 -
rockethj8:
client 㓟有一个参数是可以忽略一些URL 不进行验证登录 ...
SSO 之 (单点登录)实施中遇到的几个问题 -
mengxiangfeiyan:
好啊。。。。。
Oracle删除表,删除数据以及恢复数据、利用现有表创建新表
http://zhangjunhd.blog.51cto.com/113473/23690
本文将介绍如何使用Tomcat5.0和Apache Axis2开发、部署及测试一个简单的Web Service应用。
author: ZJ 07-3-12
Blog: http://zhangjunhd.blog.51cto.com/
1.工作环境
Eclipse 3.1.2+Lomboz+jdk1.5+ apache-tomcat-5.0.18+AXIS2:1.0(war版本和bin版本)
在http://ws.apache.org/axis2/download/1_0/download.cgi页面下,下载AXIS2的Binary Distribution url: http://apache.justdn.org/ws/axis2/1_0/axis2-std-1.0-bin.zip和war Distribution url: http://apache.justdn.org/ws/axis2/1_0/axis2-1.0-docs.zip。把这两个文件解压,比如解压缩的后得目录为C:\axis2-std-1.0-bin和C:\axis2.war。
在Eclipse下通过菜单window—preferences…--Java—Build Path—User Libraries 新建一个user library,比如名字就叫axis2把C:\axis2-std-1.0-bin\lib下的所有jar文件包含进来。把axis2.war拷贝到%TOMCAT-HOME%/webapps下面。
2.检验安装
在Eclipse下启动Tomcat,在地址栏内输入http://localhost:8080/axis2/。
点击Validate,将到达 Axis2 Happiness Page。
3.WebService中的HelloWorld
1)新建一个动态web工程,取名ZZaxis,右键点击项目名,选择Properties-Java Build Path-Add Library-User Library-axis2。
2)新建package sample,建立HelloWorld.java,代码如下。
HelloWorld.java
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
public class HelloWorld {
public OMElement sayHello(OMElement in){
String name=in.getText();
String info=name+"HelloWorld!";
OMFactory fac=OMAbstractFactory.getOMFactory();
OMNamespace omNs=fac.createOMNamespace("http://helloworld.com/","hw");
OMElement resp=fac.createOMElement("sayHelloResponse",omNs);
resp.setText(info);
return resp;
}
}
3)在WebContent\META-INF\建立services.xml,代码如下。
services.xml
<?xml version="1.0" encoding="UTF-8"?>
<service name="HelloWorld">
<description>
This is a sample Web Service.
</description>
<parameter name="ServiceClass" locked="false">sample.HelloWorld</parameter>
<operation name="sayHello">
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
</operation>
</service>
4)将目录sample和目录META-INF组织如下(新建目录example)。
+-example
|-------- +-sample
|------- HelloWorld.class
|---------+-META-INF
|------- services.xml
5)打包生成aar文件。
在命令符环境下,将当前目录转到example。
jar cvf HelloWorld.aar . //注意最后一个点,在当前目录下生成HelloWorld.aar。
6)在Eclipse中启动Tomcat,在地址栏下键入http://localhost:8080/axis2/。选择Administration,输入用户名admin,密码axis2。选择左侧工具栏Tools- Upload Service,上传之前打包的HelloWorld.aar。该文件将在<CATALINA_HOME>/webapps/axis2\WEB-INF\services目录下。
7)编写客户端检验代码。新建Java Project,取名为ZZaxisClient。右键点击项目名,选择Properties-Java Build Path-Add Library-User Library-axis2。
8)新建package example.client。建立TestClient.java,代码如下。
TestClient.java
package example.client;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
public class TestClient {
private static EndpointReference targetEPR=new EndpointReference
("http://localhost:8080/axis2/services/HelloWorld");
public static OMElement getSayHelloOMElement(){
OMFactory fac=OMAbstractFactory.getOMFactory();
OMNamespace omNs=fac.createOMNamespace("http://helloworld.com/","hw");
OMElement method=fac.createOMElement("sayHello",omNs);
method.setText("ZJ");
return method;
}
public static void main(String[] args){
try{
Options options=new Options();
options.setTo(targetEPR);
ServiceClient sender=new ServiceClient();
sender.setOptions(options);
OMElement sayHello=TestClient.getSayHelloOMElement();
OMElement result=sender.sendReceive(sayHello);
System.out.println(result);
}
catch(Exception axisFault){
axisFault.printStackTrace();
}
}
}
9)测试,run TestClient.java as Java Application。结果:
<hw:sayHelloResponse xmlns:hw="http://helloworld.com/"
xmlns:tns="http://ws.apache.org/axis2">
ZJHelloWorld!
</hw:sayHelloResponse>
4.后续
详细介绍client和server端代码。《基于Tomcat5.0和Axis2开发Web Service代码详解 》http://zhangjunhd.blog.51cto.com/113473/23690
本文将介绍如何使用Tomcat5.0和Apache Axis2开发、部署及测试一个简单的Web Service应用。
author: ZJ 07-3-12
Blog: http://zhangjunhd.blog.51cto.com/
1.工作环境
Eclipse 3.1.2+Lomboz+jdk1.5+ apache-tomcat-5.0.18+AXIS2:1.0(war版本和bin版本)
在http://ws.apache.org/axis2/download/1_0/download.cgi页面下,下载AXIS2的Binary Distribution url: http://apache.justdn.org/ws/axis2/1_0/axis2-std-1.0-bin.zip和war Distribution url: http://apache.justdn.org/ws/axis2/1_0/axis2-1.0-docs.zip。把这两个文件解压,比如解压缩的后得目录为C:\axis2-std-1.0-bin和C:\axis2.war。
在Eclipse下通过菜单window—preferences…--Java—Build Path—User Libraries 新建一个user library,比如名字就叫axis2把C:\axis2-std-1.0-bin\lib下的所有jar文件包含进来。把axis2.war拷贝到%TOMCAT-HOME%/webapps下面。
2.检验安装
在Eclipse下启动Tomcat,在地址栏内输入http://localhost:8080/axis2/。
点击Validate,将到达 Axis2 Happiness Page。
3.WebService中的HelloWorld
1)新建一个动态web工程,取名ZZaxis,右键点击项目名,选择Properties-Java Build Path-Add Library-User Library-axis2。
2)新建package sample,建立HelloWorld.java,代码如下。
HelloWorld.java
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
public class HelloWorld {
public OMElement sayHello(OMElement in){
String name=in.getText();
String info=name+"HelloWorld!";
OMFactory fac=OMAbstractFactory.getOMFactory();
OMNamespace omNs=fac.createOMNamespace("http://helloworld.com/","hw");
OMElement resp=fac.createOMElement("sayHelloResponse",omNs);
resp.setText(info);
return resp;
}
}
3)在WebContent\META-INF\建立services.xml,代码如下。
services.xml
<?xml version="1.0" encoding="UTF-8"?>
<service name="HelloWorld">
<description>
This is a sample Web Service.
</description>
<parameter name="ServiceClass" locked="false">sample.HelloWorld</parameter>
<operation name="sayHello">
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
</operation>
</service>
4)将目录sample和目录META-INF组织如下(新建目录example)。
+-example
|-------- +-sample
|------- HelloWorld.class
|---------+-META-INF
|------- services.xml
5)打包生成aar文件。
在命令符环境下,将当前目录转到example。
jar cvf HelloWorld.aar . //注意最后一个点,在当前目录下生成HelloWorld.aar。
6)在Eclipse中启动Tomcat,在地址栏下键入http://localhost:8080/axis2/。选择Administration,输入用户名admin,密码axis2。选择左侧工具栏Tools- Upload Service,上传之前打包的HelloWorld.aar。该文件将在<CATALINA_HOME>/webapps/axis2\WEB-INF\services目录下。
7)编写客户端检验代码。新建Java Project,取名为ZZaxisClient。右键点击项目名,选择Properties-Java Build Path-Add Library-User Library-axis2。
8)新建package example.client。建立TestClient.java,代码如下。
TestClient.java
package example.client;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
public class TestClient {
private static EndpointReference targetEPR=new EndpointReference
("http://localhost:8080/axis2/services/HelloWorld");
public static OMElement getSayHelloOMElement(){
OMFactory fac=OMAbstractFactory.getOMFactory();
OMNamespace omNs=fac.createOMNamespace("http://helloworld.com/","hw");
OMElement method=fac.createOMElement("sayHello",omNs);
method.setText("ZJ");
return method;
}
public static void main(String[] args){
try{
Options options=new Options();
options.setTo(targetEPR);
ServiceClient sender=new ServiceClient();
sender.setOptions(options);
OMElement sayHello=TestClient.getSayHelloOMElement();
OMElement result=sender.sendReceive(sayHello);
System.out.println(result);
}
catch(Exception axisFault){
axisFault.printStackTrace();
}
}
}
9)测试,run TestClient.java as Java Application。结果:
<hw:sayHelloResponse xmlns:hw="http://helloworld.com/"
xmlns:tns="http://ws.apache.org/axis2">
ZJHelloWorld!
</hw:sayHelloResponse>
4.后续
详细介绍client和server端代码。《基于Tomcat5.0和Axis2开发Web Service代码详解 》http://zhangjunhd.blog.51cto.com/113473/23690
发表评论
-
rest 之 主题笔记
2014-03-22 09:59 7681、Web 服务主要有三种形式:SOAP、REST 和 RPC ... -
架构Web Service 之 描述与注册,发布Web服务
2013-06-12 19:31 0架构Web Service: 描述与注 ... -
soap wsdl
2013-06-12 19:29 0Web Service概述 Web Service的定义 ... -
Axis2 之 开发Java Web服务
2013-06-12 19:28 0概述 本文介绍了一个比较简单实用的基于Java的S ... -
Axis2 之 利用JiBX把XML转换Web服务
2013-06-12 19:18 0[ http://blog.csdn.net/phantomh ... -
AXIS2 之 Axis序列化/反序列化器开发指南
2013-06-12 19:15 0薛谷雨 rainight@126.com 联系。 http:/ ... -
Axis2 之 复合类型数据的传递
2013-06-12 18:50 0axis2开发指南 http://www.360doc.com ... -
Axis 之 soap wsdl
2013-06-12 18:01 0http://www.mohappy.com/blog/use ... -
Axis1.4
2013-06-12 17:58 0http://www.blogjava.net/xiaodao ... -
Axis 之 开发详细注释
2013-06-12 17:55 0http://www.360doc.com/content/1 ... -
Axis 之 WebService测试,开发,部署
2013-06-12 17:52 0带抓图的word文档在:http://618119.com/d ... -
axis 之 传递复杂类型
2013-06-12 17:49 1305从客户端除了传递字符串以外还可以传递复杂对象(对象必须序列化了 ... -
Axis 之 axis三种开发方式
2013-06-12 17:43 1444Tomcat+Axis+Eclipse实例讲解 一、 ... -
在AXIS服务间传递JavaBean及其安全解决
2013-06-12 17:17 2567-------------------1、AXIS学习笔记-- ... -
web Service客户端调用
2013-06-12 16:30 0客户端调用 目前我用了2种调用方法 Client.java p ... -
利用HttpURLConnection实现SOAP调用
2013-05-26 21:42 6232我们完全可以利用J2SE中 ... -
WebService总结1
2012-09-28 23:31 1124web service大致有三 ... -
JAVA中三种WebService规范及底层实例
2012-09-28 23:19 3697http://www.360doc.com/conte ... -
WebService大讲堂系列之Axis2
2012-09-28 01:28 929http://www.360doc.com/conte ... -
Axis2+wsdl2java.bat生成客户端调用
2012-09-28 00:45 27571http://www.360doc.com/c ...
相关推荐
NULL 博文链接:https://tw5566.iteye.com/blog/324072
基于_Tomcat5.0和_Axis2开发Web_Service应用实例
基于Tomcat5_0和Axis2开发Web Service应用实例,上面的例子简单实用
Axis+MyEclipse6.0+Tomcat5.0开发Web Service实例总结
随着Web Service技术迅速发展,基于Web Service开发的应用被使用...本文将介绍如何使用WAS CE(WebSphere Application Server Community Edition)和Apache Axis2开发、部署及测试一个简单的Web Service应用-网上花店。
Axis开发Web Service实例Axis开发Web Service实例
用axis2开发web service,过程比用axis1开发web service简单
基于AXIS2实现Web Service开发
基于Axis2和Tomcat的自动化可配置Web Service开发文档,源码和测试工程代码,详细讲述了如何在Tomcat环境下利用Axis2引擎快速开发一个可配置的自动化发布的web service应用。
基于Axis2的Web Service 快速开发.ppt
贴一个关于用AXIS来开发Webservice 的一个不错的例子,也可以与大家一起分享之。。。。
web service在web接口系统中是jms中很不错的一个选择。而axis又是开发web service的不二人选。本文通过理论结合实例的方式讲解如何通过axis来开发web service。所有实例代码均可copy运行成功。
用axis2开发Web Services,内容包括环境搭建,插件安装,以及用axis2开发Web Services的详细步骤及实例程序;
java基于Axis2调用C#开发的web service获取xml结果
一个完整的web项目 基于axis2的web服务开发 包含完整代码和文档以及操作指南 请勿随意转载上传 所用到的其他技术包括但不限于:java web、mysql、Axis2、Html5、CSS2等 所用到的工具包括但不限于:eclipse、 Photo...
Axis2创建web service快速入门