package simple.client.example;import java.net.MalformedURLException;
import java.rmi.RemoteException;
import java.util.ArrayList;import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;/**
*
* @author xr.xia
* 从webService中获得ArrayList类型的数据
*/public class JdbcArrayListTest { public static void main(String[] args) {
//下面两种访问路径效果相同
String endpoint = "http://100.1.139.104:8080/TestWeb/services/JdbcArrayList";
//String endpoint = "http://localhost:8080/TestWeb/services/JdbcArrayList?wsdl";
String parameter = "11";
try {
Service service = new Service();
Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName("selectValue"); //你要调用的方法名称
call.addParameter("parameter", XMLType.XSD_STRING, ParameterMode.IN); //传进去的参数值
call.setReturnType(new QName("ArrayList"),ArrayList.class); //返回参数的类型 ArrayList list = (ArrayList)(call.invoke(new Object[]{parameter}));; //获取返回值 System.out.println("Got result : " + list);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
} }}
呵呵,这样就可以得到list的参数了
import java.rmi.RemoteException;
import java.util.ArrayList;import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;/**
*
* @author xr.xia
* 从webService中获得ArrayList类型的数据
*/public class JdbcArrayListTest { public static void main(String[] args) {
//下面两种访问路径效果相同
String endpoint = "http://100.1.139.104:8080/TestWeb/services/JdbcArrayList";
//String endpoint = "http://localhost:8080/TestWeb/services/JdbcArrayList?wsdl";
String parameter = "11";
try {
Service service = new Service();
Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName("selectValue"); //你要调用的方法名称
call.addParameter("parameter", XMLType.XSD_STRING, ParameterMode.IN); //传进去的参数值
call.setReturnType(new QName("ArrayList"),ArrayList.class); //返回参数的类型 ArrayList list = (ArrayList)(call.invoke(new Object[]{parameter}));; //获取返回值 System.out.println("Got result : " + list);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
} }}
呵呵,这样就可以得到list的参数了
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货