1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| @Slf4j public class ComplexTestCase { @Test @SneakyThrows public void testAxis1Complex() { String webServiceUrl = "http://127.0.0.1:8080/axisServer/v1/call?wsdl";
CommonDTO requestDTO = new CommonDTO(); requestDTO.setCompany("ABC"); requestDTO.setType(123); requestDTO.setServerFlag(false); List<String> managerList = new ArrayList<>(); managerList.add("张三"); managerList.add("李四"); managerList.add("王五"); requestDTO.setManagerList(managerList);
CommonDTO responseDTO = callComplexType(webServiceUrl, "acceptInfo", requestDTO);
log.info(JSON.toJSONString(responseDTO, true)); }
private CommonDTO callComplexType(String webServiceUrl, String methodName, CommonDTO commonDTO) throws ServiceException, RemoteException, MalformedURLException { Service service = new Service(); Call call = (Call) service.createCall();
call.setTimeout(30000); call.setOperationName(new QName(methodName)); call.setTargetEndpointAddress(webServiceUrl);
QName qName = new QName("urn:commonDTO", "common"); call.registerTypeMapping(CommonDTO.class, qName, new BeanSerializerFactory(CommonDTO.class, qName), new BeanDeserializerFactory(CommonDTO.class, qName)); call.addParameter("arg1", qName, ParameterMode.IN); call.setReturnClass(CommonDTO.class);
return (CommonDTO) call.invoke(new Object[]{commonDTO}); } }
|