To invoke a LiveCycle process from an application
built with Flex, perform the following tasks:
-
Create a
mx:RemoteObject
instance.
-
Create a
ChannelSet
instance.
-
Pass required input values.
-
Handle return values.
Note:
This section discusses how to invoke a LiveCycle process and upload a document when LiveCycle is
configured to upload unsecure documents. For information about how
to invoke LiveCycle processes and upload secure documents
and how to configure LiveCycle to accept secure and unsecure
documents, see
Passing secure documents to invoke processes using Remoting
.
Creating a mx:RemoteObject instance
You create a
mx:RemoteObject
instance
to invoke a LiveCycle process created in Workbench. To create
a
mx:RemoteObject
instance, specify the following
values:
-
id:
The name of the
mx:RemoteObject
instance
that represents the process to invoke.
-
destination:
The name of the LiveCycle process
to invoke. For example, to invoke the
MyApplication/EncryptDocument
process, specify
MyApplication/EncryptDocument
.
-
result:
The name of the Flex method that handles the
result.
Within the
mx:RemoteObject
tag,
specify a
<mx:method>
tag that specifies the
name of the process’s invocation method. Typically, the name of
a LiveCycle invocation method is
invoke
.
The
following code example creates a
mx:RemoteObject
instance
that invokes the
MyApplication/EncryptDocument
process.
<mx:RemoteObject id="EncryptDocument" destination="MyApplication/EncryptDocument" result="resultHandler(event);">
<mx:method name="invoke" result="handleExecuteInvoke(event)"/>
</mx:RemoteObject>
Create a Channel to LiveCycle
A client application can
invoke LiveCycle by specifying a Channel in MXML or ActionScript,
as the following ActionScript example shows. The Channel must be
an
AMFChannel
,
SecureAMFChannel
,
HTTPChannel
,
or
SecureHTTPChannel
.
...
private function refresh():void{
var cs:ChannelSet= new ChannelSet();
cs.addChannel(new AMFChannel("my-amf",
"http://yourlcserver:8080/remoting/messagebroker/amf"));
EncryptDocument.setCredentials("administrator", "password");
EncryptDocument.channelSet = cs;
}
...
Assign the
ChannelSet
instance
to the
mx:RemoteObject
instance’s
channelSet
field
(as shown in the previous code example). Generally, you import the
channel class in an import statement rather than specifying the
fully qualified name when you invoke the
ChannelSet.addChannel
method.
Passing input values
A process created in Workbench can take zero
or more input parameters and return an output value. A client application
passes input parameters within an
ActionScript
object
with fields that correspond to parameters that belong to the LiveCycle process. The short-lived process, named
MyApplication/EncryptDocument
,
requires one input parameter named
inDoc
. The name
of the operation exposed by the process is
invoke
(the default
name for a short-lived process). (See
Invoking LiveCycle using Remoting
.)
The following
code example passes a PDF document to the
MyApplication/EncryptDocument
process:
...
var params:Object = new Object();
//Document is an instance of DocumentReference
//that store an unsecured PDF document
params["inDoc"] = pdfDocument;
// Invoke an operation synchronously:
EncryptDocument.invoke(params);
...
In this code example,
pdfDocument
is
a
DocumentReference
instance that contains an unsecured
PDF document. For information about a
DocumentReference
,
see
Handling documents with Remoting
.
Invoking a specific version of a service
You can invoke a specific
version of a LiveCycle service by using a
_version
parameter
in the invocation's parameter map. For example, to invoke version
1.2 of the
MyApplication/EncryptDocument
service:
var params:Object = new Object();
params["inDoc"] = pdfDocument;
params["_version"] = "1.2"
var token:AsyncToken = echoService.echoString(params);
The
version
parameter
must be a string containing a single period. The values to the left,
major version, and right, minor version, of the period must be integers. If
this parameter is not specified, the head active version is invoked.
Handling return values
LiveCycle process output parameters
are deserialized into ActionScript objects from which the client
application extracts specific parameters by name, as the following
example shows. (The output value of the
MyApplication/EncryptDocument
process
is named
outDoc
.)
...
var res:Object = event.result;
var docRef:DocumentReference = res["outDoc"] as DocumentReference;
...