欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

axis测试https开头的webservice webservicejavaaxis 

程序员文章站 2024-03-25 17:51:04
...

我用的是maven做项目架构,所以项目中加入axis1.4。在项目的pom。xml中增加

<dependency>
			<groupId>axis</groupId>
			<artifactId>axis-jaxrpc</artifactId>
			<version>1.4</version>
		</dependency>

 java代码如下:

package test;
import javax.xml.namespace.QName;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
/**
 * 
 * @author gshen
 *
 */
public class TestEcVoteNotice {
	  public static void main(String [] args) throws Exception {  
	        System.setProperty("javax.net.ssl.keyStore", "D:\\SSL\\client.keystore");  
	        System.setProperty("javax.net.ssl.keyStorePassword", "xmkjbgs");  
	        System.setProperty("javax.net.ssl.trustStore", "D:\\SSL\\client.truststore");  
	        System.setProperty("javax.net.ssl.trustStorePassword", "xmkjbgs");  
	        
	      //wsdl地址
			String endpoint = "https://192.168.1.146:8443/task/ws/getInfoService?wsdl";
			//http://jarfiles.pandaidea.com/ 搜索axis.jar并下载,Service类在axis.jar
			Service service = new Service();
			//http://jarfiles.pandaidea.com/ 搜索axis.jar并下载,Call类在axis.jar
			Call call = null;
			try {
				call = (Call) service.createCall();
				//设置Call的调用地址
				call.setTargetEndpointAddress(new java.net.URL(endpoint));
				//根据wsdl中 <wsdl:import location="https://192.168.10.24:8443/ShinService/HelloWorld?wsdl=HelloService.wsdl" 
				//namespace="http://server.cxf.shinkong.cn/" /> ,
				//<wsdl:operation name="findALL">
				call.setOperationName(new QName("http://ws.task.xm.com/","sayHello"));  
				 //参数1对应服务端的@WebParam(name = "tableName") 没有设置名称为arg0
	            //调用方法的返回值
	            call.setReturnType(org.apache.axis.Constants.XSD_STRING);  
	            //调用用Operation调用存储过程(以服务端的方法为准)
				String res = (String) call.invoke(new Object[] {});  //调用存储过程
				System.out.println(res);
			} catch (Exception e) {
				
			}
	      }  
}

 直接run运行就ok了,会直接在eclipse命令行打出server端的打印结果