使用Axis开发Web Service程序-入门

本文介绍了如何配置和使用Apache Axis服务。主要包括下载安装包、配置环境变量、通过DOS命令创建、调用和删除服务的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天看了一个上午Axis,现在终于可以调通了,主要是在http://www.williamlong.info/archives/701.html,http://www.iteye.com/topic/56552学到的.
首先自己在http://ws.apache.org/axis/下载Axis安装包,我用的是axis-bin-1_4.zip.
原来原理并没有他们写的那么复杂,首先要了解几个DOS命令,下面引用JavaEye一个网友(onlykwx )的话:
这是我按版主说的执行历史,希望对后边看的兄弟有点帮助:
1、启动你的应用服务器(当然是部署好axis后)
2、进入samples\userguide\example3目录

创建服务:
java org.apache.axis.client.AdminClient -lhttp://localhost:80/axis/services/AdminService deploy.wsdd
调用服务:
java samples.userguide.example3.Client -lhttp://localhost:80/axis/services/MyService "test me!"
删除服务:
java org.apache.axis.client.AdminClient -lhttp://localhost:80/axis/services/AdminService undeploy.wsdd

(具体IP及端口根据本地实际情况进行修改)



第一步:在测试axis之前我们需要一些准备工作。我们首先要把axis用到的jar包添加到CLASSPATH环境变量中去。如下:

C:\tomcat5\webapps\axis\WEB-INF\lib\axis.jar;

C:\tomcat5\webapps\axis\WEB-INF\lib\jaxrpc.jar;

C:\tomcat5\webapps\axis\WEB-INF\lib\saaj.jar;

C:\tomcat5\webapps\axis\WEB-INF\lib\commons-discovery-0.2.jar;

C:\tomcat5\webapps\axis\WEB-INF\lib\commons-logging-1.0.4.jar;

C:\tomcat5\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar;

C:\tomcat5\webapps\axis\WEB-INF\lib\activation.jar;

C:\tomcat5\webapps\axis\WEB-INF\lib\mail.jar

第二步:运行cmd

Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>cd E:\axis\axis-1_4\samples\userguide\example3

C:\Documents and Settings\Administrator>e:

E:\axis\axis-1_4\samples\userguide\example3>java org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis/services/AdminService deploy.wsdd
2007-12-24 9:33:08 org.apache.axis.utils.JavaUtils isAttachmentSupported
警告: Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
Processing file deploy.wsdd
<Admin>Done processing</Admin>

E:\axis\axis-1_4\samples\userguide\example3>cd E:\axis\axis-1_4

E:\axis\axis-1_4>java samples.userguide.example3.Client -lhttp://localhost:8080/axis/services/MyService "test me!"
2007-12-24 9:33:29 org.apache.axis.utils.JavaUtils isAttachmentSupported
警告: Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
You typed : test me!

E:\axis\axis-1_4>cd E:\axis\axis-1_4\samples\userguide\example3

E:\axis\axis-1_4\samples\userguide\example3>java org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis/services/AdminService undeploy.wsdd
2007-12-24 9:33:45 org.apache.axis.utils.JavaUtils isAttachmentSupported
警告: Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
Processing file undeploy.wsdd
<Admin>Done processing</Admin>

E:\axis\axis-1_4\samples\userguide\example3>java org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis/services/AdminService deploy.wsdd
2007-12-24 9:35:37 org.apache.axis.utils.JavaUtils isAttachmentSupported
警告: Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
Processing file deploy.wsdd
Exception: AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.net.ConnectException: Connection refused: connect
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Conne
ction refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
ketFactory.java:153)
at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
ketFactory.java:120)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:1
91)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.ja
va:404)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)

at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
y.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:1792)
at org.apache.axis.client.AdminClient.process(AdminClient.java:439)
at org.apache.axis.client.AdminClient.process(AdminClient.java:404)
at org.apache.axis.client.AdminClient.process(AdminClient.java:410)
at org.apache.axis.client.AdminClient.process(AdminClient.java:320)
at org.apache.axis.client.AdminClient.main(AdminClient.java:463)

{http://xml.apache.org/axis/}hostname:CHINA-FE2F3804B


E:\axis\axis-1_4\samples\userguide\example3>

如果没启动tomcat或者找不到地址就会报上面的错误,上面的警告是因为我没设置某些包的环境变量
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值