org.as2lib.core.BasicClass +--org.as2lib.io.conn.core.client.AbstractClientServiceProxy +--org.as2lib.io.conn.local.client.LocalClientServiceProxy
ClientServiceProxy
LocalClientServiceProxy
handles client requests to a certain service
and its responses.
Example:
var client:LocalClientServiceProxy = new LocalClientServiceProxy("local.as2lib.org/myService");
var callback:MethodInvocationCallback = client.invoke("myMethod", ["firstArgument", "secondArgument"]);
callback.onReturn = function(returnInfo:MethodInvocationReturnInfo):Void {
trace("myMethod - return value: " + returnInfo.getReturnValue());
}
callback.onError = function(errorInfo:MethodInvocationErrorInfo):Void {
trace("myMethod - error: " + errorInfo.getException());
}
It is also possible to call the method directly on the proxy. But you can't
type the proxy then.
var client = new LocalClientServiceProxy("local.as2lib.org/myService");
var callback:MethodInvocationCallback = client.myMethod("firstArgument", "secondArgument");
The neatest way is to use LocalClientServiceProxyFactory
to get a proxy
for a service interface or class, which enables compiler checks. For more
information on this refer to the LocalClientServiceProxyFactory class.
If the return value is not of type Number
, Boolean
, String
or Array
that are converted directly into the appropriate type you must
do the following to receive a value of correct type. Otherwise the return value
will be an instance of type Object that is populated with the instance variables
of the sent object. Note that this must be done on the client as well as on the
server and the 'symbolId' in this case "MyClass"
must be the same.
Object.registerClass("MyClass", MyClass);
The received object will now be of correct type. But you still have to be aware
of some facts:
Flash creates a new object in the background and sets the instance variables of
the sent instance to the new object. It then registers this object with the
appropriate class (if registered previously) and applies the constructor of that
class to the new object passing no arguments. This means if the constructor sets
instance variables it overwrites the ones set previously by undefined
.
invoke(), invokeByName(), invokeByNameAndArguments(), invokeByNameAndCallback()
public function LocalClientServiceProxy(url:String)
Constructs a new LocalClientServiceProxy
instance.
url | the url of the service |
IllegalArgumentException | if url is null , undefined
or an empty string
|
static public function generateResponseServiceUrl(serviceUrl:String, methodName:String):String
Generates the response url for a service.
The response url is composed as follows:
theServiceUrl.theMethodName_Return_theIndex
If the passed-in methodName
is null
, undefined
or an
empty string the response url will be composed as follows:
theServiceUrl_Return_theIndex
index
is a number from 0 to infinite depending on how many responses
are pending.
serviceUrl | the url to the service |
methodName | the name of the responsing method |
the generated response url
IllegalArgumentException | if the passed-in serviceUrl is null ,
undefined or an empty stirng
|
public function getUrl(Void):String
Returns the url of the service this proxy invokes methods on.
The returned url is never null
, undefined
or an empty string.
the url of the service this proxy invokes methods on
public function invokeByNameAndArgumentsAndCallback(methodName:String, args:Array, callback:MethodInvocationCallback):MethodInvocationCallback
Invokes the method with passed-in methodName
on the 'remote' service,
passing the elements of the passed-in args
as parameters and invokes
the appropriate method on the passed-in callback
on response.
The response of the method invocation is delegated to the appropriate method
on the passed-in callback
. This is either the onReturn
when no
error occured, or the onError
method in case something went wrong.
If the passed-in callback
is null
a new MethodInvocationCallback
instance will be created and returned. It is possible to still set the callback
methods there, after invoking this method.
methodName | the name of the method to invoke on the 'remote' service |
args | the arguments that are passed to the method as parameters |
callback | the callback that handles the response |
either the passed-in callback or a new callback if null
IllegalArgumentException | if the passed-in methodName is null ,
undefined or an empty string
|
invokeByNameAndArgumentsAndCallback() in org.as2lib.io.conn.core.client.ClientServiceProxy