Create
Java application logic that invokes the FirstAppSolution/PreLoanProcess process
from within the Java servlet. The following code shows the syntax
of the SubmitXML Java Servlet:
public class SubmitXML extends HttpServlet implements Servlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp
throws ServletException, IOException {
doPost(req,resp);
}
public void doPost(HttpServletRequest req, HttpServletResponse resp
throws ServletException, IOException {
//Add code here to invoke the FirstAppSolution/PreLoanProcess process
}
Normally, you would not place client code within a Java servlet’s doGet or doPost method.
A better programming practice is to place this code within a separate
class. Then instantiate the class from within the doPost method
(or doGet method), and call the appropriate methods.
However, for code brevity, code examples are kept to a minimum and
are placed in the doPost method.
To invoke the FirstAppSolution/PreLoanProcess process
using the Invocation API, perform the following tasks:
Include client JAR files, such as adobe-livecycle-client.jar,
in your Java project’s class path. For information about the location
of these files, see Including LiveCycle Java library files.
Retrieve the name, phone, and amount values that is submitted
from the HTML page. Use these values to dynamically create an XML
data source that is sent to the FirstAppSolution/PreLoanProcess process.
You can use org.w3c.dom classes to create the XML
data source (this application logic is shown in the following code
example).
Create a ServiceClientFactory object that
contains connection properties. (See Setting connection properties.)
Create a ServiceClient object by using its
constructor and passing the ServiceClientFactory object.
A ServiceClient object lets you invoke a service
operation. It handles tasks such as locating, dispatching, and routing
invocation requests.
Create a java.util.HashMap object by using
its constructor.
Invoke the java.util.HashMap object’s put method
for each input parameter to pass to the long-lived process. Ensure
that you specify the name of the process’s input parameters. Because
the FirstAppSolution/PreLoanProcess process requires
one input parameter of type XML (named formData),
you only have to invoke the put method once.
//Get the XML to pass to the FirstAppSolution/PreLoanProcess process
org.w3c.dom.Document inXML = GetDataSource(name,phone,amount);
//Create a Map object to store the parameter value
Map params = new HashMap();
params.put("formData", inXML);
Create an InvocationRequest object by invoking
the ServiceClientFactory object’s createInvocationRequest method
and passing the following values:
A string value that
specifies the name of the long-lived process to invoke. To invoke
the FirstAppSolution/PreLoanProcess process, specify FirstAppSolution/PreLoanProcess.
A string value that represents the process operation name.
The name of the long-lived process operation is invoke.
The java.util.HashMap object that contains
the parameter values that the service operation requires.
A Boolean value that specifies false, which
creates an asynchronous request (this value is applicable to invoke
a long-lived process).
Note: A short-lived process can be invoked by passing the value true as the fourth parameter of the createInvocationRequest method. Passing the value true creates a synchronous request.
Send the invocation request to LiveCycle by invoking the ServiceClient object’s invoke method
and passing the InvocationRequest object. The invoke method
returns an InvocationReponse object.
A long-lived process returns a string value that represents
an invocation identification value. Retrieve this value by invoking
the InvocationReponse object’s getInvocationId method.
//Send the invocation request to the long-lived process and
//get back an invocation response object
InvocationResponse lcResponse = myServiceClient.invoke(lcRequest);
String invocationId = lcResponse.getInvocationId();
Write the invocation identification value to the client web
browser. You can use a java.io.PrintWriter instance
to write this value to the client web browser.
|
|
|