public InvocationResponse invokeMethod(InvocationRequest request) {
		String methodName = request.getMethodName();

		if (!mMethodIndex.containsKey(methodName)) {
			String msg = String.format(ErrorMsg.METHOD_NOT_FOUND, methodName, mServiceDescriptor.getServiceName());
			return InvocationResponse.error(msg);
		}

		Method m = mMethodIndex.get(methodName);
		Object[] params;
		try {
			params = deserializeParameters(request.getPayload(), m.getGenericParameterTypes());
		} catch (ServiceInvocationException e) {
			return InvocationResponse.error("Error deserializing parameters:" + e.getMessage());
		}

		try {
			Object result = m.invoke(mImplementation, params);
			String json = GsonHelper.gson.toJson(result);
			return InvocationResponse.result(json);
		} catch (IllegalAccessException e) {
			return InvocationResponse.error(e);
		} catch (IllegalArgumentException e) {
			return InvocationResponse.error(ErrorMsg.ILLEGAL_ARGUMENT);
		} catch (InvocationTargetException e) {
			return InvocationResponse.error(e.getCause());
		}
	}
public InvocationResponse invokeMethod(InvocationRequest request) {
		String methodName = request.getMethodName();

		if (!mMethodIndex.containsKey(methodName)) {
			String msg = String.format(ErrorMsg.METHOD_NOT_FOUND, methodName, mServiceDescriptor.getServiceName());
			return InvocationResponse.error(msg);
		}

		Method m = mMethodIndex.get(methodName);
		Object[] params;
		try {
			params = deserializeParameters(request.getPayload(), m.getGenericParameterTypes());
		} catch (ServiceInvocationException e) {
			return InvocationResponse.error("Error deserializing parameters:" + e.getMessage());
		}

		try {
			Object result = m.invoke(mImplementation, params);
			String json = GsonHelper.gson.toJson(result);
			return InvocationResponse.result(json);
		} catch (IllegalAccessException e) {
			return InvocationResponse.error(e);
		} catch (IllegalArgumentException e) {
			return InvocationResponse.error(ErrorMsg.ILLEGAL_ARGUMENT);
		} catch (InvocationTargetException e) {
			return InvocationResponse.error(e.getCause());
		}
	}
public InvocationResponse invokeMethod ( InvocationRequest request ) { String methodName = request . getMethodName ( ) ; if ( ! mMethodIndex . containsKey ( methodName ) ) { String msg = String . format ( ErrorMsg . METHOD_NOT_FOUND , methodName , mServiceDescriptor . getServiceName ( ) ) ; return InvocationResponse . error ( msg ) ; } Method m = mMethodIndex . get ( methodName ) ; Object [ ] params ; try { params = deserializeParameters ( request . getPayload ( ) , m . getGenericParameterTypes ( ) ) ; } catch ( ServiceInvocationException e ) { return InvocationResponse . error ( "Error deserializing parameters:" + e . getMessage ( ) ) ; } try { Object result = m . invoke ( mImplementation , params ) ; String json = GsonHelper . gson . toJson ( result ) ; return InvocationResponse . result ( json ) ; } catch ( IllegalAccessException e ) { return InvocationResponse . error ( e ) ; } catch ( IllegalArgumentException e ) { return InvocationResponse . error ( ErrorMsg . ILLEGAL_ARGUMENT ) ; } catch ( InvocationTargetException e ) { return InvocationResponse . error ( e . getCause ( ) ) ; } }
Invokes a method of the service.

@param request
- The invocation request
@return the return value
@throws IllegalInvocationException
if the request does not match the service
@throws InvocationTargetException
if an Exception is thrown during execution
Invokes a method of the service .