用axis将hello.jws部署成ws:
hello.jws:
--------------
import java.lang.*;
public class Hello
{
public String hello(String name)
{
if (name==null)
name="";
String st="你好"+name+",欢迎来到WebService的世界!";
return st;
}
}
--------------
通过
http://localhost:8080/axis/hello.jws可以访问,wsdl也没有问题
然后按照飞鹰的教程写一个调用类:wsTest.java:
wsTest.java:
--------------
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 wsTest{
public static void main(String[] args){
String endPoint="http://localhost:8080/axis/Hello.jws";
try{
Service service=new Service();
Call call=(Call) service.createCall();
call.setTargetEndpointAddress(endPoint);
call.setOperationName("hello");
call.addParameter("op1",XMLType.XSD_STRING,ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING);
String name="Web Service echo:";
System.out.println("servers says:"+call.invoke(new Object[]{name}));
}catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}
---------------------
编译通过,可是运行时报错:
---------------------
java.lang.NoClassDefFoundError: org.apache.commons.logging.LogFactory
at org.apache.axis.components.logger.LogFactory.class$(LogFactory.java:84)
at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:84)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:80)
at org.apache.axis.components.logger.LogFactory.<clinit>(LogFactory.java:72)
at org.apache.axis.handlers.BasicHandler.<clinit>(BasicHandler.java:81)
at org.apache.axis.client.Service.getAxisClient(Service.java:143)
at org.apache.axis.client.Service.<init>(Service.java:152)
at wsTest.main(wsTest.java:11)
Exception in thread "main"
----------------------
请大家帮忙看看这是什么原因:(
着急的说:((
--
FROM 162.105.3.*