1.  服务端(项目名:server)

1.1.  Axis1.4环境搭建

1)下载axis1.4文件【点击下载】,复制axis-1_4\lib所有jar包到server\WebRoot\WEB-INF\lib

2)在server\WebRoot\WEB-INF下新增server-config.wsdd文件内容如下

 
 
  
        
          
          
          
          
      
      
    
    
         
         
         
         
         
         
    
    
         
            
               
            
         

3)server\WebRoot\WEB-INF\web.xml加入内容:



  
    index.jsp
  
  
  	
       
         AxisServlet  
         org.apache.axis.transport.http.AxisServlet  
       
       
         AxisServlet  
         /services/*  
       
    
     
        index.html 
        index.htm 
        index.jsp 
        default.html 
        default.htm 
        default.jsp 
     
  
  

1.2.  编写webservice类和方法

package com.sdxjd.webservice;

public class Server {
	
	public String getName(String name){ 
        return "Hello ,"+name; 
    }
	
}

1.3.  Tomcat部署,打开浏览器访问地址:

http://localhost:8080/server/services

2.  客户端(项目名:client)

2.1.   使用jdk自带的wsimport命令生成客户端,命令如下:

wsimport -keep -pcom.sdjxd.base http://localhost:8080/server/services/Server.jws?wsdl

复制生成的java文件到客户端 client\src路径下

2.2.   编写客户端类和方法

package com.sdjxd.client;

import com.sdjxd.base.Server;
import com.sdjxd.base.ServerService;

public class Client {
	
	public static void main(String args[]){
		Server server = new ServerService().getServer();
		String res = server.getName("webservice");
		System.out.println(res);
	}
	
}
本文转载于:https://www.yisu.com/zixun/355434.html 如有侵犯,请联系zhengruancom@outlook.com删除。
免责声明:正软商城发布此文仅为传递信息,不代表正软商城认同其观点或证实其描述。