package cn.shinkong.cxf.server.impl;
import java.net.MalformedURLException;
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 Test {
public static void main(String[] args) {
// System.setProperty("javax.net.ssl.keyStore", "D:\\tomcat.keystore");//注意是絕對路徑
// System.setProperty("javax.net.ssl.keyStorePassword", "123456");
// System.setProperty("javax.net.ssl.trustStore", "D:\\tomcat.keystore");
// System.setProperty("javax.net.ssl.trustStorePassword", "123456");
//wsdl地址
String endpoint = "https://192.168.10.24:8443/ShinService/HelloWorld?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://server.cxf.shinkong.cn/","findALL"));
//參數1對應服務端的@WebParam(name = "tableName") 沒有設置名稱爲arg0
call.addParameter("tableName", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
//沒有設置名稱爲agr1
call.addParameter("fieldList", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
//沒有設置名稱爲agr2
call.addParameter("paramMap", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
//調用方法的返回值
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
//調用用Operation調用存儲過程(以服務端的方法爲準)
String res = (String) call.invoke(new Object[] {"call Q_XB('2013-1-1','2014-3-1','1','','','','')","","" }); //調用存儲過程
System.out.println(res);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}