Interface org.as2lib.io.conn.core.event.MethodInvocationCallback

Description

MethodInvocationCallback awaits the response of a method invocation.

There are two types of responses.

Return Response:
Indicates that the method has been invoked successfully without throwing an exception.
Error Response:
Indicates that an error occured when trying to invoke the method. This error can for example be an exception the method threw or the unavailability of the method to invoke. For further details take a look at the '*_Error' constants declared by MethodInvocationErrorInfo.

Depending on the client and service used, that are responsible for propagating the methods on this callback, there may be other circumstances on which a specific callback method is invoked.

This interface can either be instantiated directly or implemented by a class. If you instantiate it directly you must overwrite the callback methods you wanna be informed of with anonymous functions.

Note that implementing this interface is much cleaner and less error-prone. It is thus recommended to implement this interface whenever possible, instead of overwriting the methods with anonymous functions. Note also that the direct instantiation of interfaces is not permitted in Flex. var callback:MethodInvocationCallback = new MethodInvocationCallback(); callback.onReturn = function(returnInfo:MethodInvocationReturnInfo):Void) { trace("Invoked method successfully: " + returnInfo); } callback.onError = function(errorInfo:MethodInvocationErrorInfo):Void { trace("Error occured when trying to invoke the method: " + errorInfo); }

Implementing the interface by a class is a much neater way. But sometimes it adds unnecessary complexity. class MyCallback implements MethodInvocationCallback { public function onReturn(returnInfo:MethodInvocationReturnInfo):Void { trace("Invoked method successfully: " + returnInfo); } public function onError(errorInfo:MethodInvocationErrorInfo):Void { trace("Error occured when trying to invoke the method: " + errorInfo); } }

Method Index

onError(), onReturn()

Inherited from BasicInterface

Method Detail

onReturn

public function onReturn(returnInfo:MethodInvocationReturnInfo):Void

Is executed when the return value of the method invocation arrives.

This indicates that the method was invoked successfully.

Parameters

returnInfocontains the return value and some other useful information about the invoked method

onError

public function onError(errorInfo:MethodInvocationErrorInfo):Void

Is executed when a method invocation fails.

Known issues are:

  • The method threw an exception.
  • The method does not exist on the remote service.

Remember that not all clients support this functionalities.

Parameters

errorInfocontains information about the error and some useful information about the called method