1. 环境准备
下载wtp-all-in-one-sdk-R-1.5.4-win32,这个是eclipse的web开发插件。
2. 新建一个动态web工程(dynamic web project),命名为DynamicAxisClient。
eclips>>file>>new>>project>>web>>Dynamic web project
3. 写服务端代码(HelloWorld.java)
package com.dynamic.axis.server;
public class HelloWorld {
public String sayHello(String name) {
return "你好,世界!";
}
}
4. 发布服务
右键点击HelloWorld.java>>new>>other>>Web Services>>Web service>>next>>next>>start server>>Finish。
webcontent目录下会自动生成一个文件wsdl文件夹,文件夹中包含HelloWorld.wsdl文件,WEB-INF目录下会生成server-config.wsdd,HelloServiceService目录文件,lib文件夹中生成了axis的jar文件>>服务端部署成功。
打开浏览器,输入:http://localhost:8080/DynamicAxisServer/services
5. 生成服务器代码
右击webcontent\wsdl\HelloWorld.wsdl文件>>new>>other>>Web Services>>Web service>>next>>next>>Finish。
src目录下会自动生成com\dynamic\axis\server包,包中包含6个java文件(HelloWorld.java|HelloWorldService.java|HelloWorldServiceLocator.java|HelloWorldSoapBindingImpl.java|HelloWorldSoapBindingSkeleton.java|HelloWorldSoapBindingStub.java)
webcontent目录下会自动生成一个文件类的包文件与2个wsdd文件.
6. 在HelloWorldSoapBindingImpl.java文件中编写服务器实现代码.
7. 客户端程序测试
创建java工程,导入axis相关包,编写客户端测试代码,如下:
package com.dynaic.axis.client;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class TestAxisClient {
public static void main(String[] args) {
String endPoint = "http://localhost:8080/DynamicAxisServer/services/HelloWorld";
Service service = new Service();
try {
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endPoint);
call.setOperationName(new QName("urn:HelloService", "sayHello"));
String returnValue = (String) call.invoke(new Object[] {});
System.out.println(returnValue);
} catch (ServiceException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
分享到:
相关推荐
MyEclipse下开发Web Service(Axis)
Web Service WebService Axis一个完整的客户端代码
MyEclipse下开发Web Service(Axis2)
web service 使用 axis2 框架使用的插件 必不可少的
Web Service (Axis 1.1) step by step.ppt 用AXIS开发webservice一步
Axis开发Web Service实例,介绍AXIS的三种方法
web service axis 1.6。配置说明,客户端,服务端代码
MyEclipse下开发Web Service(Axis)2,步骤简单清晰。
web service axis1.4所有的jar
Web Service Axis1.4 完整的实例,WebService Axis1.4 完整的实例。
axis1实现helloWorld 博文链接:https://yehao0716.iteye.com/blog/1535268
.Web Service简介 .如何开发一个Web Service .Axis2简介 .Axis2安装与部署 .Web Service开发步骤
用axis2开发web service,过程比用axis1开发web service简单
Web Service Axis2-1.6.2框架使用 压缩包里有:文档说明,axis2-1.6.2-bin.zip、axis2-1.6.2-war.zip、axis2-eclipse-codegen-plugin-1.6.2.zip、axis2-eclipse-service-plugin-1.6.2.zip。文档里用的所有jar压缩包...
NULL 博文链接:https://yehao0716.iteye.com/blog/1542231
博文链接:https://linxizeng.iteye.com/blog/130027
web service Axis2相关jar 里面包含了Axis2 java调用.net接口所需jar包
Chapter 6, Information Model - Learn how Axis2 stores it static and dynamic data and the importance of it. Chapter 7, Writing an Axis2 Service - Learn how to write a simple-complex service using Axis...