Invoking Output Service (transformPDF) via SOAP

This tutorial provides a simple example of how to call a LiveCycle service from ColdFusion using SOAP. The article specifically calls the transFormPDF method of the OutputService, however provides the basics for calling any service.

Normally the preferred method of invoking LiveCycle services from ColdFusion is probably using the EJB, sometimes this can be difficult and SOAP provides a simple solution, although not the most robust.

Using the SOAP enoint requires knowledge of the specific WSDL file for the desired service. A list of WSDL file locations can be found here.

transformPDF.cfm
<!— Change OutputServiceURL to match your environment —>
< cfset OutputServiceURL = "http://127.0.0.1:8080/soap/services/OutputService?wsdl">

<!— Change SourceFileName to point to a PDF Form —>
<cfset SourceFileName = "C:\Temp\Test.pdf">

<!— Convert the PDF Form to Binary, BASE64 —>
<cffile action="READBINARY" file="#SourceFileName#" variable="sourcePDF">
<cfset binaryData = ToBase64(sourcePDF, "iso-8859-1")>

<cfoutput>
<CFSAVECONTENT VARIABLE="SoapRequestXML">
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<m:transformPDF xmlns:m="http://adobe.com/idp/services">
<m:inPdfDoc>
<m:contentType>String</m:contentType>
<m:binaryData>#binaryData#</m:binaryData>
<m:attachmentID>String</m:attachmentID>
<m:remoteURL>String</m:remoteURL>
</m:inPdfDoc>
<m:transformationFormat>PDF</m:transformationFormat>
<m:pdfaRevisionNumber>Revision_1</m:pdfaRevisionNumber>
<m:pdfaAmendment>String</m:pdfaAmendment>
<m:pdfaConformance>A</m:pdfaConformance>
</m:transformPDF>
v/SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</CFSAVECONTENT>
</cfoutput>

<!— Invoke the Web Service —>
<cfhttp url="#OutputServiceURL#" method="POST" username="administrator" password="password">
<cfhttpparam type="CGI" name="SOAPAction" value="transformPDF">
<cfhttpparam type="XML" name="transformPDFRequest" value="#SoapRequestXML#">
</CFHTTP>

<!— Parse the Result —>
<cfset SoapResponseXML = #cfhttp.filecontent#>
<cfset SoapResponseXML = xmlParse(SoapResponseXML)>
<cfset theRoot = SoapResponseXML.XmlRoot>
<cfset readerEnabledPDF = ‘#theRoot.XmlChildren[1].XmlChildren[1].XmlChildren[1]["remoteURL"].XmlText#’>

<cfoutput>
<a href="#readerEnabledPDF#" target="_blank">Transformed PDF</a>
</cfoutput>

You can also download the source here Download Source