I was writing a servlet to call the Render QPac but had difficulty passing data as I would keep getting an error "Content no allowed in prolog". The data I was passing was valid xml but realised it was a limitation of the QPac. I could have wrote the xml data file to disk then passed the path but that isn't a great solution.
I discovered I could duplicate the functionality of the Render QPac (with more versatility). You can pass in your process variables from your servlet
Add the following code to your script QPac:
import com.adobe.fm.FMConstants;
import com.adobe.formServer.client.EJBClient;
import com.adobe.formServer.interfaces.IFormServer;
import com.adobe.formServer.interfaces.IOutputContext;
import com.adobe.formServer.interfaces.RenderFormException;
import com.adobe.idp.Context;
import com.adobe.idp.um.api.AuthenticationManager;
import com.adobe.idp.um.api.UMException;
import com.adobe.idp.um.api.UMFactory;
import com.adobe.idp.um.api.UMConstants;
import com.adobe.idp.um.api.infomodel.AuthResult;
import com.adobe.idp.Document;
import com.adobe.workflow.pat.service.PATAbstractService;
import com.adobe.workflow.pat.service.PATExecutionContext;
import com.adobe.workflow.pat.service.PATServiceException;
import com.adobe.workflow.pat.service.PATServiceResult;
import com.adobe.workflow.pat.service.PATServiceContext;
Context context = null;
IOutputContext iOutputContext=null;
String formTemplate="";
String formPref="";
Document data=null;
String options="";
String userAgent="";
String webRoot="";
String targetURL="";
String contentURI="";
String baseURL="";
com.adobe.idp.Document outDoc=null;
try {
AuthenticationManager manager = UMFactory.getInstance().getAuthenticationManager();
Context context = new Context();
AuthResult result = manager.getAuthResultOnBehalfOfUser(
"LiveCycle Form Manager System User",
UMConstants.SpecialDefaultPrincipals.DOMAIN_DEFAULT,
new Context());
context.initPrincipal(result);
IFormServer oFS = new EJBClient();
if(oFS!=null){
oFS.setInvocationContext(context);
}
formTemplate = patExecContext.getProcessDataStringValue("/process_data/@templatepath");
formPref = patExecContext.getProcessDataStringValue("/process_data/@formpref");
data = (Document)patExecContext.getProcessDataValue("/process_data/@data");
options = patExecContext.getProcessDataStringValue("/process_data/@options");
targetURL = patExecContext.getProcessDataStringValue("/process_data/@targeturl");
contentURI = patExecContext.getProcessDataStringValue("/process_data/@contenturi");
baseURL = patExecContext.getProcessDataStringValue("/process_data/@baseurl");
iOutputContext = oFS.renderForm(formTemplate, //template name
formPref, //render preference
data, options, userAgent, webRoot, //App URL
targetURL, contentURI, //ContentRoot URI
baseURL);
outDoc = new com.adobe.idp.Document(iOutputContext.getOutputContent());
outDoc.setContentType(iOutputContext.getContentType());
patExecContext.setProcessDataValue("/process_data/@output",outDoc);
} catch (UMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (RenderFormException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}