使用的Eclipse版本Eclipse JEE 3.3,JDK版本1.5,Tomcat6.0。在这个Eclipse版本里已集成了Axis1.4的插件,无需安装任何插件就可以开发Web Service应用程序了,利用图形化的向导可以开发Web Service服务端和客户端程序。
建立一个项目AxisServerDemo,写一个简单的类:
package demo.axis;
public class User
{
public String sayHello(String userName)
{
return "hello " + userName;
}
}
public class User
{
public String sayHello(String userName)
{
return "hello " + userName;
}
}
下面用Axis向导把这个bean发布为Web Service:
1、选择File|New|Other,选择新建Web Service。
图1 选择新建Web Service
2、在第一步的界面上点击“next”,出现一个界面:
图2 指定对哪个类生成Web Service
点击“Web service Apache Axis”,出现以下界面:
图3 选择Axis版本
此处选择Apache Axis。
对图2界面上选择要生成的类,点击“next”。
3、选择要生成Web Service的方法,如下图:
图4 选择要生成Web Service的方法
4、在如下界面,启动应用服务器。
图5 启动应用服务器
在应用服务器启动后,点击“next”。
5、在Web Service发布界面上,因为仅仅是一个测试,不选择发布,点击“finish”。
图6 选择发布Web Service
按步骤完成以后,会在项目中生成一些文件,web.xml也已被修改,在lib中会多出来几个.jar文件,最后目录结构如下:
图7 生成Web Service后的目录结构
把项目部署到tomcat中,启动后在浏览器中输入“http://localhost:8080/AxisServerDemo/services/User?wsdl”,能够看到xml格式wsdl就说明成功了。
刚才完成的Web Service发布了一个简单的功能,如何利用它呢,利用这个功能的就是Web Service 客户端。下面利用Axis1.4插件自动生成访问Web Service的代码。
新建一个项目AxisClientDemo,用以下步骤生成Web Service客户端代码:
1、选择File|New|Other,选择新建Web Service Client。
图8 选择新建Web Service Client
2、在接下来的界面中,输入Web Service所在的URL,此处是“http://localhost:8080/AxisServerDemo/services/User?wsdl”。
图9 输入Web Service的wsdl所在的路径
3、选择生成代码所在的路径。
图10 选择生成代码所在的路径
4、点击“Finish”,就会生成几个java文件,lib目录下面会多出几个.jar文件。生成之后的代码结构如下:
图11 生成Web Service客户端代码后的目录结构
为了测试Web Service客户端代码是否工作正常,在建立一个jsp文件:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="demo.axis.User"%>
<%@page import="demo.axis.UserProxy"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form method="POST">
<input type="text" name="username"/>
<br/>
<input type="submit" value="ok"/>
</form>
<%
String userName = request.getParameter("username");
if (userName != null && !"".equals(userName))
{
User user = new UserProxy();
out.print(user.sayHello(userName));
}
%>
</body>
</html>
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="demo.axis.User"%>
<%@page import="demo.axis.UserProxy"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form method="POST">
<input type="text" name="username"/>
<br/>
<input type="submit" value="ok"/>
</form>
<%
String userName = request.getParameter("username");
if (userName != null && !"".equals(userName))
{
User user = new UserProxy();
out.print(user.sayHello(userName));
}
%>
</body>
</html>
启动tomcat,在浏览器中运行上面的jsp文件,就可以看到效果了。
相关推荐
axis1.4生成客户端 根据WSDL生成客户端和服务端
axis1.4生成访问客户端代码
eclipse使用axis1.4发布联通vac的webservice服务代码,并有客户端测试
Axis1.4从服务端到客户端图文攻略,同时附赠Axis1.4 Jar包。 本攻略经过多次测试可靠耐用,并同时带有详细的文字说明,保证一学就会!从现在起axis不再是问题!让你爱上web service!
内有axis1.4jar包以及使用eclipse和axis1.4 将WSDL和服务端代码互转方法 亲测可用
【java项目整合Axis1.4webservice搭建实例】客户端代码
Axis1.4开发指南 介绍Axis1.4的开发方式,并附上不少范例代码
axis1.4完整包下载Apache Axis是一种SOAP(简单对象访问协议”)实现。 包含 Axis1.4的所有完整包。
web service axis1.4所有的jar
axis1.4和axis2相关jar文件,axis1.4和axis2相关jar文件
用于axis1.4开发webService。 文件包含,axis1.4.ZIP以及其他所需jar包,和生成webservice客户端,生成webService服务端发布 的详细教程说明。
本方法是用axis1.4技术,实现java客户端调用webservice。已经可实现过可行的,如果不行可加我QQ号302633进行详细解析。
Axis1.4开发指南.pdf axis-bin-1_4.zip axis相关文档 axis1.4 开发jar包
MyEclipse的axis1.4 java的webservice客户端服务端,下载即可直接运动,包括lib
springboot 集成axis1.4的webservice,该为maven的工程
java org.apache.axis.wsdl.WSDL2Java -u http://xxxxxx?wsdl -p com.webservice.wsdl -t -u 要访问的webservice的地址标准的wsdl文件 -p 生成java文件的包名 -t 生成的java文件中包含junit的测试代码。 详见...
该包中含有: 1.axis1.4-bin.zip 2.wsdl2java.bat批处理脚本 3.客户端调用时缺失的mail.jar和activation.jar,没有这两个包执行客户端代码可能会报错。
Axis1.4如何实现头部鉴权(包括实现类模板)