Jboss3.0.7_tomcat_4.1.24的axis配置
author:帅牛士 email:[email protected]
一.把C:\jboss-3.0.7_jakarta-tomcat-4.1.24\server\all\deploy目录里的jboss-net.sar文件解压,把里面的文件解到jboss-net.sar目录里,然后把jboss-net.sar文件备份到其它目录,如c:\根目录下,并把C:\jboss-3.0.7_jakarta-tomcat-4.1.24\server\all\deploy\jobss-net.sar文件删除
二.启动jboss(run –c all),在ie地址栏里输入http://localhost:port/axis/*/services ,可以看到以下的文字,说明配置成功
axis/*/servicesHi there, this is an AXIS service!
Perhaps there will be a form for invoking the service here...
三.建wsr文件
例子:写一个testHelloWorld.java文件,编译成class
内容:public class testHelloWorld
{
public HelloWorld() {
}
public String getHelloWorldMessage(String name){
return "Hello world to " + name;
}
}
在testHelloWorld文件的目录里建一个META-INF目录,META-INF里建一个web-service.xml文件,
内容:<!-- Example Web Service Descriptor -->
<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="testHelloWorld" provider="java:RPC">
<parameter name="className" value="testHelloWorld"/>
<parameter name="allowedMethods" value=" getHelloWorldMessage"/>
</service>
</deployment>
到testHelloWorld文件目录里使用jar命令打包:jar cvf testHelloWorld.wsr ,把testHelloWorld.wsr 拷贝到C:\jboss-3.0.7_jakarta-tomcat-4.1.24\server\all\deploy\目录里。
四.写个客户端class调用(当然php,asp也可以调用),内容:
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;
public class testClient1
{
public static void main(String [] args) {
try {
String endpoint =
"http://192.168.0.28:8080/axis/*/services/testHelloWorld";
String methodName = "getHelloWorldMessage";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName(methodName);
// Call to addParameter/setReturnType as described in user-guide.html
call.addParameter("name",
org.apache.axis.Constants.XSD_STRING,
ParameterMode.PARAM_MODE_IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
String ret = (String) call.invoke( new Object[] { "AXIS!" } );
System.out.println(ret);
} catch (Exception e) {
System.err.println(e.toString());
e.printStackTrace();
}
}
}
执行此class,如打印出 Hello world to AXIS!就ok了。
本文地址:http://com.8s8s.com/it/it16476.htm