webservice调用接口,接口返回数组类型
1.
其中sendSyncMsg1接口是方法名,Vector实现了List接口,xml是sendSyncMsg1的方法形参
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL( "http://127.0.0.1:8080/services/fangkunTest"));
call.setOperationName(new QName("http://127.0.0.1:8080/", "sendSyncMsg1"));
call.addParameter(new QName("http://127.0.0.1:8080/", "xml"), XMLType.XSD_STRING, ParameterMode.IN); //必须这么用,不知道为啥,此处与返回基本类型写法有差别
call.setReturnType(XMLType.SOAP_VECTOR); //返回时数组类型,暂时知道用XMLType.SOAP_VECTOR
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://127.0.0.1:8080/sendSyncMsg1");
Vector result = (Vector) call.invoke(new Object[] { "昆明" });
// Vector实现了List接口
System.out.println((String) result.get(1));
if (result != null && result.size() != 0) {
if (result.get(0).equals("1")) {
String etoken = (String) result.get(1);
} else {
System.out.println(result.get(2));
return;
}
}
2.(转来自google)
Java利用Axis远程调用WebService接口
posted on 2016-01-26 13:49 struggle_beiJing 阅读(7065) 评论(0) 编辑 收藏 举报