1.demo
try {
// 1.创建对象
String result = "返回值异常"; // 定义异常时返回结果
Call call = (Call) new Service().createCall();
// 2.设置访问url
call.setTargetEndpointAddress(endPoint);
// 3.设置访问地址的方法
call.setOperationName("wsGetMultiInfos");
//4.设置参数属性名:
call.addParameter("nCataId", XMLType.XSD_INT, javax.xml.rpc.ParameterMode.INOUT);
call.addParameter("bRef", XMLType.XSD_INT, javax.xml.rpc.ParameterMode.INOUT);
call.addParameter("iBase64", XMLType.XSD_INT, javax.xml.rpc.ParameterMode.INOUT);
call.addParameter("nStart", XMLType.XSD_INT, javax.xml.rpc.ParameterMode.INOUT);
call.addParameter("nEnd", XMLType.XSD_INT, javax.xml.rpc.ParameterMode.INOUT);
call.addParameter("bAsc", XMLType.XSD_INT, javax.xml.rpc.ParameterMode.INOUT);
call.addParameter("strStartCTime", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.INOUT);
call.addParameter("trEndCTime", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.INOUT);
call.addParameter("strLoginId", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.INOUT);
call.addParameter("strPwd", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.INOUT);
call.addParameter("strKey", XMLType.XSD_STRING, ParameterMode.INOUT);
// 5.封装参数(与上边一一对应)
Object[] object = new Object[11];
object[0] = map.get("nCataId");
object[1] = 1;
object[2] = 0;
object[3] = map.get("nStart");
object[4] = map.get("nEnd");
object[5] = map.get("bAsc");
object[6] = map.get("strStartCTime");
object[7] = map.get("trEndCTime");
object[8] = username;
object[9] = password;
object[10] = "";
// 6.设置接收值类型:
call.setReturnType(XMLType.XSD_STRING); //返回值类型:String
result = (String) call.invoke(object); //远程调用
System.out.println(result);
} catch (javax.xml.rpc.ServiceException | RemoteException e) {
e.printStackTrace();
}
2.需要的jar包
解压之后只需要导入对应的jar即可
axis.jar.zip