今天开始从头学习java web服务开发的学习,主要是axis的学习,在这里做个笔记,以后再看可也记得住
在布置axis环境是,在classpath中有toors.jar,在tomcat中也有toors.jar,当然在axi中也有的了,但是浏览器浏览jws文件时,报错,说是让我添加toors,jar文件,不知道为什么了,想到难道是jdk版本和axis不兼容,就把tomcat的jdk换成1.6了,果然可以了,但是具体内部是不是这个问题,还是不很清楚。。。
下面是第一种发布方式:即时发布(Instant Deloyment)
- public class HelloWorldJWS {
- public String test(String a,String b){
- String result = "a="+a+" ,b="+b;
- System.out.println("Received is"+result);
- return "Server Response OK,you send: "+result;
- }
- }
然后是客户端
- 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 ClientJWS {
- /**
- * @param args
- * @throws ServiceException
- * @throws RemoteException
- */
- public static void main(String[] args) throws ServiceException, RemoteException {
- // TODO Auto-generated method stub
- String url = "http://localhost:8000/axis/HelloWorldJWS.jws";
- Service service = new Service();
- Call call = (Call)service.createCall();
- call.setTargetEndpointAddress(url);
- call.setOperationName(new QName(url,"test"));
- String result = (String)call.invoke(new Object[]{"diandian","100"});
- System.out.println("result="+result);
- }
- }
在运行客户端时还需要在工程类库中添加commons-logging-1.0.4.jar ,commons-discovery.jar,即时发布不支持带包的类。
第一次作业笔记