1.demo

  1. try {
  2. // 1.创建对象
  3. String result = "返回值异常"; // 定义异常时返回结果
  4. Call call = (Call) new Service().createCall();
  5. // 2.设置访问url
  6. call.setTargetEndpointAddress(endPoint);
  7. // 3.设置访问地址的方法
  8. call.setOperationName("wsGetMultiInfos");
  9. //4.设置参数属性名:
  10. call.addParameter("nCataId", XMLType.XSD_INT, javax.xml.rpc.ParameterMode.INOUT);
  11. call.addParameter("bRef", XMLType.XSD_INT, javax.xml.rpc.ParameterMode.INOUT);
  12. call.addParameter("iBase64", XMLType.XSD_INT, javax.xml.rpc.ParameterMode.INOUT);
  13. call.addParameter("nStart", XMLType.XSD_INT, javax.xml.rpc.ParameterMode.INOUT);
  14. call.addParameter("nEnd", XMLType.XSD_INT, javax.xml.rpc.ParameterMode.INOUT);
  15. call.addParameter("bAsc", XMLType.XSD_INT, javax.xml.rpc.ParameterMode.INOUT);
  16. call.addParameter("strStartCTime", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.INOUT);
  17. call.addParameter("trEndCTime", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.INOUT);
  18. call.addParameter("strLoginId", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.INOUT);
  19. call.addParameter("strPwd", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.INOUT);
  20. call.addParameter("strKey", XMLType.XSD_STRING, ParameterMode.INOUT);
  21. // 5.封装参数(与上边一一对应)
  22. Object[] object = new Object[11];
  23. object[0] = map.get("nCataId");
  24. object[1] = 1;
  25. object[2] = 0;
  26. object[3] = map.get("nStart");
  27. object[4] = map.get("nEnd");
  28. object[5] = map.get("bAsc");
  29. object[6] = map.get("strStartCTime");
  30. object[7] = map.get("trEndCTime");
  31. object[8] = username;
  32. object[9] = password;
  33. object[10] = "";
  34. // 6.设置接收值类型:
  35. call.setReturnType(XMLType.XSD_STRING); //返回值类型:String
  36. result = (String) call.invoke(object); //远程调用
  37. System.out.println(result);
  38. } catch (javax.xml.rpc.ServiceException | RemoteException e) {
  39. e.printStackTrace();
  40. }

2.需要的jar包

解压之后只需要导入对应的jar即可
axis.jar.zip

打包找不到第三方jar解决方案