Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Livecycle workflow 7.2.2 + asembler QPAC : Web services

Avatar

Former Community Member
Hello,



I'm trying do develop a webservice for use Assembler.

In order to do this i have install livecycle woklow and livecycle assembler.



i 've done all that is specified in the different document :



Create a workflow with workflow designer, deploy it, use the code for the soap client like it xas writtent ine the doc.



But it don't seems to work, so i need help.



/***************************************************

Workflow designer :

****************************************************/

- creation of a workflow with only one component wich reprensent de assembler QPAC.

- creation of the variable input : "inputdocmap" for the input pdf

- creation of the variable output : "outputmap" for the ouput pdf

- define a static ddx file

- associate my outpumap variable with "output document map"



/***************************************************

java code

***************************************************/



//BODY



MessageFactory messageFactory = MessageFactory.newInstance();

SOAPMessage soapMessage = messageFactory.createMessage();

SOAPPart soapPart = soapMessage.getSOAPPart();

SOAPEnvelope requestEnvelope = soapPart.getEnvelope();

SOAPBody body = requestEnvelope.getBody();

Name elementName = requestEnvelope.createName("synchronousInvoke");

SOAPBodyElement bodyElement= body.addBodyElement(elementName);



//ATTACHEMENT



String inputDocumentFilename = "c:\\step1.pdf";

FileDataSource fileDataSource = new FileDataSource(new

File(inputDocumentFilename));

DataHandler dataHandler = new DataHandler(fileDataSource);

AttachmentPart attachment = soapMessage.createAttachmentPart(dataHandler);

attachment.setContentType(fileDataSource.getContentType());

attachment.setContentId("file1");

soapMessage.addAttachmentPart(attachment);

SOAPElement inputDocument = bodyElement.addChildElement(requestEnvelope.createName("inputdocmap"));

inputDocument.addTextNode("cid:" + attachment.getContentId());



//SEND

SOAPConnectionFactory soapConnectionFactory =

SOAPConnectionFactory.newInstance();

SOAPConnection soapConnection = soapConnectionFactory.createConnection();



URL serviceURL=null;

try {

serviceURL = new URL("http://localhost:8090/services/execute");

} catch (MalformedURLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

SOAPMessage responseSOAPMessage =soapConnection.call(soapMessage,serviceURL);

soapConnection.close();



//RESPONSE



SOAPPart responseSOAPPart = responseSOAPMessage.getSOAPPart();

SOAPEnvelope responseEnvelope = responseSOAPPart.getEnvelope();

SOAPBody responseSoapBody = responseEnvelope.getBody();

Iterator iterator = responseSoapBody.getChildElements();

SOAPElement responseBodyElement = (SOAPElement) iterator.next();

String responseAttachmentContentID = null;

System.out.println(responseBodyElement);

iterator = responseBodyElement.getChildElements();

while (iterator.hasNext()) {

SOAPElement outputParameter = (SOAPElement)iterator.next();

String elementType = outputParameter.getElementName().getLocalName();

String attachmentID="";

if (elementType == "ProcessID")

System.out.println("Process ID = "+ outputParameter.getValue());

else if (elementType == "outputmap")

attachmentID = outputParameter.getValue();



attachmentID = attachmentID.substring("cid:".length());



attachment = null;



iterator = responseSOAPMessage.getAttachments();

while (iterator.hasNext()) {

attachment=(AttachmentPart)iterator.next();

if (attachment.getContentId() == attachmentID){

break;

}

}



try {

DataHandler attachmentDataHandler = attachment.getDataHandler();

DataSource attachmentDataSource = attachmentDataHandler.getDataSource();

InputStream attachmentInputStream = attachmentDataSource.getInputStream();

byte[] doc = new byte[attachmentInputStream.available()];

attachmentInputStream.read(doc);

File outputfile = new File("C:\\" + "output_document.pdf"
1 Reply

Avatar

Former Community Member
next ...
File outputfile = new File("C:\\" + "output_document.pdf");

FileOutputStream fileResponseOutputStream = new FileOutputStream(outputfile);
fileResponseOutputStream.write(doc);
fileResponseOutputStream.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

/************************************************
SOAP SEND MESSAGE METHOD
************************************************/

cid:file1


/************************************************
SOAP RESPOND MESSAGE
************************************************/





112




Client application runs on a tomcat Server, and lifecycle product are deployed on a jboss server. Both are on the same machine.

thanks.

P.S: Sorry for my english.