微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

初学webservice开发1----AXIS

今天开始从头学习java web服务开发的学习,主要是axis的学习,在这里做个笔记,以后再看可也记得住

 在布置axis环境是,在classpath中有toors.jar,在tomcat中也有toors.jar,当然在axi中也有的了,但是浏览器浏览jws文件时,报错,说是让我添加toors,jar文件,不知道为什么了,想到难道是jdk版本和axis不兼容,就把tomcat的jdk换成1.6了,果然可以了,但是具体内部是不是这个问题,还是不很清楚。。。

下面是第一种发布方式:即时发布(Instant Deloyment)

 
 
  1. public class HelloWorldJWS {  
  2.       
  3.     public String test(String a,String b){  
  4.         String result =  "a="+a+" ,b="+b;  
  5.         System.out.println("Received is"+result);  
  6.         return "Server Response OK,you send: "+result;  
  7.     }  

然后是客户端

 

 
 
  1. import java.rmi.remoteexception;  
  2.  
  3. import javax.xml.namespace.QName;  
  4. import javax.xml.rpc.ServiceException;  
  5.  
  6. import org.apache.axis.client.Call;  
  7. import org.apache.axis.client.Service;  
  8.  
  9.  
  10. public class ClientJWS {  
  11.  
  12.     /**  
  13.      * @param args  
  14.      * @throws ServiceException   
  15.      * @throws remoteexception   
  16.      */ 
  17.     public static void main(String[] args) throws ServiceException, remoteexception {  
  18.         // Todo Auto-generated method stub  
  19.           
  20.         String url = "http://localhost:8000/axis/HelloWorldJWS.jws";  
  21.         Service service = new Service();  
  22.         Call call = (Call)service.createCall();  
  23.         call.setTargetEndpointAddress(url);  
  24.           
  25.         call.setoperationName(new QName(url,"test"));  
  26.         String result = (String)call.invoke(new Object[]{"diandian","100"});  
  27.         System.out.println("result="+result);  
  28.           
  29.     }  
  30.  

在运行客户端时还需要在工程类库中添加commons-logging-1.0.4.jar ,commons-discovery.jar,即时发布不支持带包的类。

第一次作业笔记

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐