/** * Takes a {@link SoapCall} object and invokes the method by reflection. * * @param soapCall contains the SOAP method, SOAP client, and args to be * called * @return the response from the SOAP web service * @throws Exception thrown if calling the operation on the remote service * fails */ protected Object invoke(SoapCall<T> soapCall) throws Exception { Method soapClientMethod = soapCall.getSoapClientMethod(); Object[] soapArgs = soapCall.getSoapArgs(); soapArgs = processSoapArguments(soapClientMethod, soapArgs); return soapClientMethod.invoke(soapCall.getSoapClient(), soapArgs); } }
/** * Takes a {@link SoapCall} object and invokes the method by reflection. * * @param soapCall contains the SOAP method, SOAP client, and args to be * called * @return the response from the SOAP web service * @throws Exception thrown if calling the operation on the remote service * fails */ protected Object invoke(SoapCall<T> soapCall) throws Exception { Method soapClientMethod = soapCall.getSoapClientMethod(); Object[] soapArgs = soapCall.getSoapArgs(); soapArgs = processSoapArguments(soapClientMethod, soapArgs); return soapClientMethod.invoke(soapCall.getSoapClient(), soapArgs); } }
@Test public void testProcessArgs_null() throws Exception { Object[] args = null; Object[] processedArgs = soapClientHandler.processSoapArguments(MockSoapClient.class.getMethod("emptyCall"), args); assertNull(processedArgs); }
@Test public void testProcessArgs_emptyMethod() throws Exception { Object[] args = new Object[] {}; Object[] processedArgs = soapClientHandler.processSoapArguments(MockSoapClient.class.getMethod("emptyCall"), args); assertEquals(0, processedArgs.length); }
@Test public void testProcessArgs_tooMany() throws Exception { Object[] args = new Object[] {new Object[] {1.0d, "2", 3L}, "4"}; Object[] processedArgs = soapClientHandler.processSoapArguments(MockSoapClient.class.getMethod("emptyCall"), args); assertEquals(args[0], processedArgs[0]); assertEquals(args[1], processedArgs[1]); assertEquals(2, processedArgs.length); }
@Test public void testProcessArgs_emptyArgs() throws Exception { Object[] args = new Object[] {}; Object[] processedArgs = soapClientHandler.processSoapArguments(MockSoapClient.class.getMethod("lotsOfArgsCall", Object.class, Object[].class, Object.class, Object.class), args); assertNull(processedArgs[0]); assertNull(processedArgs[1]); assertNull(processedArgs[2]); assertNull(processedArgs[3]); assertEquals(4, processedArgs.length); }
@Test public void testProcessArgs() throws Exception { Object[] args = new Object[] {new Object[] {1.0d, "2", 3L}, "4"}; Object[] processedArgs = soapClientHandler.processSoapArguments(MockSoapClient.class.getMethod("lotsOfArgsCall", Object.class, Object[].class, Object.class, Object.class), args); assertEquals(args[0], processedArgs[0]); assertEquals(args[1], processedArgs[1]); assertNull(processedArgs[2]); assertNull(processedArgs[3]); assertEquals(4, processedArgs.length); }