for (int i = 0; i < types.length; i++) {
parameterTypes[i] = loadClass(types[i]);
}
Class returnType = loadClass(methodInfo.getReturnType());
InputStream in = null;
try {
OutputStream out = (OutputStream)stub._request(operation, true);
for (int i = 0; i < types.length; i++) {
// Object arg = (args.length < i) ? null : args[i];
writeValue(out, args[i], parameterTypes[i]);
}
if (returnType == void.class) {
// void return
stub._invoke(out);
return null;
} else {
// read the return value
in = (InputStream)stub._invoke(out);
Object response = readValue(in, returnType);
return response;
}
} catch (ApplicationException ex) {
in = (InputStream)ex.getInputStream();
String id = in.read_string();
// Check if the id matches to any declared exceptions for the
// method
String[] exceptionTypes = methodInfo.getExceptionTypes();
for (int i = 0; i < exceptionTypes.length; i++) {
Class exceptionType = loadClass(exceptionTypes[i]);
String exceptionId = ExceptionType.getExceptionType(exceptionType).getExceptionRepositoryId();
if (id.equals(exceptionId)) {
Throwable t = (Throwable)in.read_value(exceptionType);
throw new ServiceRuntimeException(t); // FIXME should
// be
// ServcieBusinessException?
// no support by
// Tuscany core