Expand my Community achievements bar.

Sample code for offline PDF forms submit to workflow

Avatar

Former Community Member
Hi,

I have a XDP form which needs to be submitted offline by the user. So i have saved the XDP as dynamic PDF. On submit of this PDF the code flows to the servlet. I am getting the following error:

"com.adobe.formServer.interfaces.ProcessFormSubmissionException: RequestBuffer not specified at com.adobe.formServer.client.EJBClient.processFormSubmission(EJBClient.java:454) at samples.triggerworkflow.servlet.ProcessFormServlet.doPost(ProcessFormServlet.java:54) at samples.triggerworkflow.servlet.ProcessFormServlet.doGet(ProcessFormServlet.java:28) at javax.servlet.http.HttpServlet.service(HttpServlet.java:697) at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at.... "

Finally i need to trigger the workflow from the servlet.



Please help me fix this error. Pleas eprovide a sample code if you have.

My servelt code is:

package samples.triggerworkflow.servlet;



import java.io.IOException;

import javax.servlet.*;

import javax.servlet.http.*;



import com.adobe.formServer.client.*;

import com.adobe.formServer.interfaces.*;

import com.adobe.idp.*;

import com.adobe.workflow.client.*;

import com.adobe.workflow.manager.*;



import samples.util.*;



/**

* @version 1.0

* @author

*/

public class ProcessFormServlet extends HttpServlet implements Servlet {



private static String failedHTML = "Process Invocation Failed. See Log";



/**

* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

*/

public void doGet(HttpServletRequest req, HttpServletResponse resp)

throws ServletException, IOException {

doPost(req, resp);

}



/**

* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

*/

public void doPost(HttpServletRequest req, HttpServletResponse resp)

throws ServletException, IOException {

EJBClient formServer = new EJBClient(Util.getInitContext(getServletContext()));



IOutputContext form = null;



try {

IOutputContext outputContext =formServer.processFormSubmission(req,"OutputType=0");

// Determine the content type -- make sure it is text/xml

String ct = outputContext.getContentType();

if ((ct.equals("text/xml"))||(ct.equals("application/vnd.adobe.xdp+xml")))

{

// Get the length of the output stream

int outLength = outputContext.getOutputContent().length;

// Create a byte array and allocate outLength bytes

byte[] formOutput = new byte[outLength];

// Populate the byte array by invoking getOutputContext

formOutput = outputContext.getOutputContent();

}

System.out.println("coming in post 5555***********");

} catch (ProcessFormSubmissionException e1) {

System.out.println("coming in exception 123***********");

e1.printStackTrace(resp.getWriter());

return;

}



String returnHtml = triggerWorkflow(form);

resp.setContentType("text/html");

resp.setContentLength(returnHtml.length());

resp.getWriter().print(returnHtml);



}



private String triggerWorkflow(IOutputContext form) {

System.out.println("coming in triggerWorkflow 1111***********");

QLCSession session = null;

String html = null;

try {

System.out.println("coming in try of triggerWorkflow 2222***********");

session = QLCSessionFactory.createSession("Localhost");

Context wkfContext = session.login("administrator", "password");

session.setContext(wkfContext);

System.out.println("coming in try of triggerWorkflow 3333***********");

ProcessManager manager = session.getProcessManager();

System.out.println("coming in try of triggerWorkflow 4444***********");

manager.setContext
0 Replies