/**
* 安装axis
*/
下载:http://ws.apache.org/axis/ 1.4
解压后把webapp/axis目录,放置于%TOMCAT_HOME%\webapps\下。
注意需要另外的lib: activation-1.1.jar, mail-1.4.jar, xercesImpl-2.8.1.jar, xml-apis-2.0.2.jar, xmlsec-1.3.0.jar
设置环境变量:
AXIS_HOME=E:\download\opensource\axis-1_4
AXIS_LIB=%AXIS_HOME%\lib
AXISCLASSPATH=%AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery-0.2.jar;%AXIS_LIB%\commons-logging-1.0.4.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar;%AXIS_LIB%\log4j-1.2.8.jar;%AXIS_LIB%\wsdl4j-1.5.1.jar;%AXIS_LIB%\xml-apis.jar;%AXIS_LIB%\xercesImpl.jar
CLASSPATH=%AXISCLASSPATH%;...
启动tomcat后,访问http://localhost:8080/axis/
查看validator确认安装是否成功。
//部署
java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient deploy.wsdd
//反部署
java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient undeploy.wsdd
//测试方法
http://localhost:8080/axis/services/LogTestService?method=testMethod&name=liwanchun//根据wsdl生成JAVA客户端
Java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java http://localhost:8080/axis/services/LogTestService?wsdl
//对于用户的认证
使用BasicHandler实现
//示例:以短信服务为例
/**
* Message.java 2007-12-31 liwanchun Exp $
* Copyright(c) 2000-2007 HC360.COM, All Rights Reserved.
*/
package com.hc360.axis;
/**
* @author: Liwanchun
*/
public class Message {
private String from;
private String to;
private String content;
private int priority;
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public String getTo() {
return to;
}
public void setTo(String to) {
this.to = to;
}
}
/**
* response.java 2007-12-31 liwanchun Exp $
* Copyright(c) 2000-2007 HC360.COM, All Rights Reserved.
*/
package com.hc360.axis;
/**
* @author: Liwanchun
*/
public class Response {
private int code;
//发送结果代码
private String errorText;
private Message message;
//发送的原始信息
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getErrorText() {
return errorText;
}
public void setErrorText(String errorText) {
this.errorText = errorText;
}
public Message getMessage() {
return message;
}
public void setMessage(Message message) {
this.message = message;
}
}
/**
* Sms.java 2007-12-31 liwanchun Exp $
* Copyright(c) 2000-2007 HC360.COM, All Rights Reserved.
*/
package com.hc360.axis;
/**
* @author: Liwanchun
*/
public class Sms {
/**
* 短信息发送Web服务接口
*/
public Response send(Message msg) throws Exception{
System.out.println("CONTENT:"+msg.getContent());
Response res = new Response();
res.setMessage(msg);
res.setCode(0);
res.setErrorText("ok");
return res;
}
}
/**
* 发布Sms
* 1、编写deploy.wsdd
* 2、发布Sms
*/
deploy.wsdd
----------------------------------------------------------------------------------
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="Sms" provider="java:RPC">
<parameter name="className" value="com.hc360.axis.Sms"/>
<parameter name="allowedMethods" value="send"/>
<beanMapping qname="myNS:Message" xmlns:myNS="urn:BeanService" languageSpecificType="java:com.hc360.axis.Message"/>
<beanMapping qname="myNS:Response" xmlns:myNS="urn:BeanService" languageSpecificType="java:com.hc360.axis.Response"/>
</service>
</deployment>
发布Sms:
----------------------------------------------------------------------------------
java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient deploy.wsdd
/**
* 根据wsdl生成JAVA客户端
*/
Java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java http://localhost:8080/axis/services/LogTestService?wsdl
该命令执行的结果是在当前所在目录下产生一个子目录BeanService和localhost目录,
------------------------------------------------------------------------------------
-- BeanService
| Message.java
| Response.java
-- localhost\axis\services\Sms
| Sms.java 定义了Web服务接口,此例中只有一个send方法。
| SmsService.java 定义了用于获取Web服务接口的方法。
| SmsServiceLocator.java 接口SmsService的具体实现
| SmsSoapBindingStub.java Web服务客户端桩,通过该类与服务器交互。
这四个JAVA类帮我们处理了大部分的逻辑,我们需要的仅仅是把这些类加到我们的项目然后创建一个我们自己的类来调用它们即可。为此我们新加一个类Main.java,为了方便,让这个类与刚产生的四个类都在同一个包下。内容如下:
/**
* Main.java 2007-12-31 liwanchun Exp $
* Copyright(c) 2000-2007 HC360.COM, All Rights Reserved.
*/
package localhost.axis.services.Sms;
import BeanService.Message;
import BeanService.Response;
/**
* @author: Liwanchun
*/
public class Main {
/**
* @param
* @return
* @throws
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
SmsService service = new SmsServiceLocator();
Sms sms = service.getSms();
Message msg = new Message();
msg.setContent("this is a test!");
msg.setFrom("hc360.com");
msg.setTo("yoobaba.com");
msg.setPriority(1);
Response resp = sms.send(msg);
Message msgRec = resp.getMessage();
System.out.println("From:" + msgRec.getFrom() + " to " +
msgRec.getTo() + ", content: " + msgRec.getContent() +
", priority: " + msgRec.getPriority() + ", code: " +
resp.getCode() + ", error code : " + resp.getErrorText());
}catch(Exception e){}
}
}
AXIS1.4安装和应用
原创
©著作权归作者所有:来自51CTO博客作者mb64be3e9157d3c的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:安装Redis
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
OpenHarmony4.0壁纸设置应用整合包和安装教程
本次整合包资源包含壁纸设置应用,已修复的手机、平板版式的启动器和安装脚本,另外平板版式的启动器,还初步修复了启动台应用显示一行的!
OpenHarmony 壁纸设置 启动器修复 安装脚本 整合包 -
axis1.4 HelloWorld
mcat 6.0.24l Jdk 1.6.0_22l Axis1.4 二、Axis简介:axis全称Apache EX...
java 开发工具 web.xml xml apache -
Springboot集成axis1.4
文章目录1. 引入依赖2. Servlet3.接口4.实现类5.配置工厂6.启动类7. server-c
axis apache spring ide -
Spring4.x整合Axis1.4发布WebService服务
一、使用Axis1.4搭建WebService服务第一步:在web.xml文件中添加映射路
WebService xml spring java -
1.4——安装Ubuntu
①打开VMvare Workstation 新建虚拟机②③④⑤⑥⑦⑧⑨10111213141516
ubuntu linux 运维 重启 Ubuntu