public String invoke(final String input, final Object serviceProvider) {
Checker.notNull("parameter:serviceProvider", serviceProvider);
ServerSerializationFactory serializationFactory = createSerializationFactory();
final ObjectInputStream inputStream = serializationFactory.createObjectInputStream(input);
final ObjectOutputStream outputStream = serializationFactory.createObjectOutputStream();
Object result = null;
boolean exceptionWasThrown = false;
Method method = null;
// read in the interface...
final String interfaceName = (String) inputStream.readObject();
final Class interfacee = this.getRequestedInterface(interfaceName);
// verify the serviceProvider actually implements $interface
this.checkServiceProvider(interfacee, serviceProvider);
// the method name...
final String methodName = (String) inputStream.readObject();
// the parameter types...
final int parameterCount = inputStream.readInt();
final String[] parameterTypes = new String[parameterCount];
for (int i = 0; i < parameterTypes.length; i++) {
parameterTypes[i] = (String) inputStream.readObject();
}
// attempt to find a method on the given interface that matches the
// method signature...
method = this.getMethod(serviceProvider.getClass(), methodName, parameterTypes);
// deserialize parameters...
final Object[] parameters = new Object[parameterCount];
for (int i = 0; i < parameterCount; i++) {
parameters[i] = inputStream.readObject();
}
// any exceptions that are thrown will be serialized and included in the
// response...
try {