1、下载 apache axis:
http://apache.etoak.com/ws/axis/1_4/
2、搭建环境:
新建一个Web项目TestWebServices
把axis-1_4\lib下的所有jar包copy到TestWebServices项目的lib项目下。
把axis-1_4\webapps\axis\WEB-INF下的Web.xml文件复制替换TestWebServices项目的Web.xml文件。
发布工程到TOMCAT里
访问
http://localhost:8080/TestWebServices/services或者
http://localhost:8080//servlet/AxisServlet
只要能出现下图 所示
[img]
[/img]
说明第一步环境搭建成功,接下来进行Web Services的核心配置。
3、用deploy.wsdd生成server-config.wsdd:
在TestWebServices项目的WEB-INF目录下编写deploy.wsdd文件
文件模板如下:
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java=
"http://xml.apache.org/axis/wsdd/providers/java">
<service name="AxisDemo" provider="java:RPC">
<parameter name="className" value="com.server.AxisDemo"/>
<parameter name="allowedMethods" value="*"/>
<parameter name="scope" value="session"/><!-- request, session, or application -->
</service>
</deployment>
根据模板中定义Class,建立一个AxisDemo的类放在包com.server下
AxisDemo类java代码如下:
package com.common;
public class AxisDemo {
public String getInfo(String aa){
return "webservice:"+aa;
}
}
用cmd进入TestWebServices项目的WEB-INF目录下Copy下面的代码到cmd窗口 回车执行
java -Djava.ext.dirs=lib org.apache.axis.client.AdminClient -lhttp://127.0.0.1:8080/TestWebServices/servlet/AxisServlet deploy.wsdd
提示如下图表示成功:
进入TomCat的TestWebServices\WEB-INF目录下可以看到server-config.wsdd已经生成。它是提供给Axis使用的配置文件。 如果没有生成请重复1,2,3
这时在访问http://localhost:8080/TestWebServices/services
会发现多了一个AxisDemo(wsdl) 尝试进行访问:
http://localhost:8080/TestWebServices/services/AxisDemo?wsdl.
4、编写客户端调用代码测试web services
package com.client;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class TestClient {
public static void main(String[] arg) throws MalformedURLException,
ServiceException, RemoteException {
String targetEndPoint = "http://127.0.0.1:8080/TestWebServices/services/AxisDemo";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(targetEndPoint));
call.setOperationName("getInfo");
String result = (String) call.invoke(new Object[] { new String("zhangsan@126.cn") });
System.out.println("result=" + result);
}
}
运行看到控制台输出:result=webservice:zhangsan@126.cn
成功。
- 大小: 13.3 KB
- 大小: 4.7 KB
- 大小: 20.7 KB
分享到:
相关推荐
Java 中,使用axis来实现webServices 里面包含Word详细说明使用webservices的步骤, 看了就会啦, 使用webServicers里面jar ,和工具都包含在里面。。。 如果你要实现webservies的话, 不看后悔死你。。。。
改文档介绍了什么是webServices、webServices的协议、以及apache中webServices框架Axis2 的应用实例开发demo. 对于想学webServices的同学有很好的帮助。
Apache Web Services Axis2(1.4.1) 详细经典入门实例,使用Eclipse Axis Plug-in,图文并茂,一看就明。
axis 实现 web services java 实例 webservices 参考:http://blog.csdn.net/chinarenzhou/article/details/7609953
Chapter 1, Apache Web Services and Axis2 - Gives you an introduction to web services and the web service stack at Apache. Chapter 2, Looking inside Axis2 - Learn about Axis2 architecture and the ...
包括3本Axis2的书(英文),實為2本(第1本有...1.Developing Web Services with Apache CXF and Axis2, 3rd Edition 2.Packt.Publishing.Quickstart.Apache.Axis2 3.Develop Web Services With Apache Axis2 PDF格式
web services Axis pdf 文件
Web Services资料大全,Web Services Axis CFX Soap 等资料。。。
用axis2开发web services 所需jar包
Develop Web services with Axis2, Part 1_ Deploy and consume simple Web service.Develop Web services with Axis2, Part 1_ Deploy and consume simple Web service
Extensive and detailed coverage of the enterprise ready Apache Axis2 Web Services / SOAP / WSDL engine. Attain a more flexible and extensible framework with the world class Axis2 architecture. Learn ...
一、Axis的安装 <br/>应用Axis开发Web Services,你需要安装如下软件: 1.JDK1.4.2或以上 2.http://ws.apache.org/axis/dist/1_1/下载得到 3.一个支持Servlet的服务器引擎,比如广为人知的Tomcat。...
用axis2开发Web Services,内容包括环境搭建,插件安装,以及用axis2开发Web Services的详细步骤及实例程序;
Develop Web Services With Apache Axis
Entwickler Press - Java Web Services Mit Apache Axis2 有点老,但比较详细介绍了axis2的使用和基本概念。是一本入门的好书
本项目是在实际开发调用webservices接口时的做的例子。使用Axis技术开发。 其中包含webservices开发,以及webservices调用。 运行项目后输入:http://localhost:8080/webserviceDemo/services/helloService?wsdl ...
axis开发webservices.doc
java axis Webservices实例
这是关于axis开发webservices的完整资料