axis测试https开头的webservice

我用的是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端的打印结果

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值