Identifying the correct MS-SQL JDBC port for the LiveCycle data source

Recently I was helping a customer with their LiveCycle installation and we could not get the “Test Database Connection” on the LiveCycle Configuration Manager’s (LCM) DataSource Configuration screen to work.  The customer was positive that they were using the default port (1433) but we always got the following error message:

Error [ALC-LCM-130-107]
Database settings failed validation.  Note: Windows Authentication on
SQL Server will fail the connection test.  See documentation for more details.

I confirmed they were using the correct driver and that they had the SQL Server configured for mixed mode authentication (not Windows Authentication).  What threw us off the most was that they were able to run a simple Java application that successfully connected to the same database from the LC server using the same driver and connection properties with one difference.  We noticed that the connection string in the Java app did not have a port defined.  So if a port is not defined it must mean it is using the default port of 1433 right?  Wrong!

It turns out that as of SQL Server 2005, Microsoft introduced something called the “SQL Server Browser” service which essentially listens for incoming requests to the SQL Server.  With this service running, requests without a defined port are automatically connected to the correct server instance.  Therefore, a connection string on the client side that has no port defined can still connect to the appropriate database as long as the correct host is defined and regardless of which port the database is configured to listen on.  The following links provide more information about the SQL Server Browser service:

http://msdn.microsoft.com/en-us/library/ms165724(v=sql.90).aspx
http://www.mssqltips.com/sqlservertip/1946/overview-of-the-sql-server-br
owser-service/ 

Once we determined what the actual port was (not 1433), the LCM data source test connection was successful.  The following article provides various ways to determine the actual listening port used by a SQL Server database instance:

http://decipherinfosys.wordpress.com/2008/01/02/finding-the-port-number-for-a-particular-sql-server-instance/

 

 

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

Invoking Output Service (transformPDF) via EJB

This sample provides the basics for invoking the transformPDF method of the LiveCycle OutputService.

This sample assumes you are using LiveCycle on Jboss. If you are using a different Java server, you will need to modify a few paramaters, but the basics are the same.

The transformPDF service transforms a interactive PDF (PDF Form) to a non-interactive PDF.

Environment Setup
1. Copy the following required jar files from your LiveCycle Installation to your {ColdFusion Install Directory}\wwwroot\WEB-INF\lib.
jbossall-client.jar [C:\Adobe\LiveCycle8\jboss\client]
adobe-utilities.jar [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\jboss]
adobe-output-client [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\common]
adobe-usermanager-client [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\common]
adobe-livecycle-client [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\common]

2. Restart ColdFusion Application Service

transformPDF_EJB.cfm
<!—
Modify these three variables to match your environment
** Be sure the fileInput is a PDF Form
—>
<cfset EJB_ENDPOINT = "jnp://68.175.120.115:1099">
<cfset fileInput = "C:\temp\test.pdf">
<cfset fileOutput = "C:\temp\output.pdf">

<cfscript>
// Create ServiceClientFactoryProperties
serviceClientFactoryProperties = CreateObject("java","com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties");
connectionProps = CreateObject("java","java.util.Properties").init();
connectionProps.setProperty(serviceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, EJB_ENDPOINT);
connectionProps.setProperty(serviceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL, serviceClientFactoryProperties.DSC_EJB_PROTOCOL);
connectionProps.setProperty(serviceClientFactoryProperties.DSC_SERVER_TYPE, "Jboss");
connectionProps.setProperty(serviceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
connectionProps.setProperty(serviceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
</cfscript>

<cfscript>
// Initialize ServiceClientFactory with serviceClientFactoryProperties
myFactory = CreateObject("java","com.adobe.idp.dsc.clientsdk.ServiceClientFactory").createInstance(connectionProps);

// Initialize FileInputStream with fileInput Variable
fileInputStream = CreateObject("java","java.io.FileInputStream").init(fileInput);

// Initialize OutputClient with ServiceClientFactory properties
outClient = CreateObject("java","com.adobe.livecycle.output.client.OutputClient").init(myFactory);

// Set inPDF Document
inPDF = CreateObject("java","com.adobe.idp.Document").init(fileInputStream);

// Set outPDF Document For Result Handling
outPDF = CreateObject("java","com.adobe.idp.Document");

// transformPDF Parameter Settings: You can avoid these properties and simply cast nulls as in the commented invoke below
TransformationFormat = CreateObject("java","com.adobe.livecycle.output.client.TransformationFormat");
PDFARevisionNumber = CreateObject("java","com.adobe.livecycle.output.client.PDFARevisionNumber");
PDFAConformance = CreateObject("java","com.adobe.livecycle.output.client.PDFAConformance");

// Initiate The transformPDF Method
outPDF = outClient.transformPDF(inPDF,TransformationFormat.PDF,PDFARevisionNumber.Revision_1,"",PDFAConformance.A);
// If you want to use null make sure you JavaCast
//outPDF = outClient.transformPDF(inPDF,TransformationFormat.PDF,JavaCast( "null", 0 ),"",JavaCast( "null", 0 ));

// Initialize FileOutputStream with fileOutput Variable
fileOutputStream = CreateObject("java","java.io.File").init(fileOutput);

// Write The File…
outPDF.copyToFile(fileOutputStream);
</cfscript>

You can also download the source here Download Source

Invoking Forms Service (renderPDFForm) via EJB

This sample provides the basics for invoking the renderPDFForm method of the LiveCycle FormsService.

This sample assumes you are using LiveCycle on Jboss. If you are using a different Java server, you will need to modify a few paramaters, but the basics are the same.

Environment Setup
1. Copy the following required jar files from your LiveCycle Installation to your {ColdFusion Install Directory}\wwwroot\WEB-INF\lib.
jbossall-client.jar [C:\Adobe\LiveCycle8\jboss\client]
adobe-utilities.jar [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\jboss]
adobe-output-client [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\common]
adobe-usermanager-client [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\common]
adobe-livecycle-client [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\common]
adobe-forms-client [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\common]

2. Restart ColdFusion Application Service

renderForm_EJB.cfm
<!—
Modify these three variables to match your environment
** Be sure the fileInput is a PDF Form XDP
—>

<cfset EJB_ENDPOINT = "jnp://68.175.120.115:1099">

<!— Document Parameters —>
<cfset inXDP = "CAR.xdp"> <!– PDF Form File Name Source: Do Not Include Path Info —>
<cfset inXML = "C:\temp\CAR.xml">
<cfset outPDF = "C:\temp\CAR1.pdf">

<!— URLSpec Parameters —>
<cfset applicationWebRoot = ”>
<cfset targetURL = ”>
<cfset contentRootURI = ‘C:\Adobe\forms\’> <!— The Directory of the inXDP file located on the LiveCycle installed server —>
<cfset baseURL = ”>

<cfscript>
// Create ServiceClientFactoryProperties
serviceClientFactoryProperties = CreateObject("java","com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties");
connectionProps = CreateObject("java","java.util.Properties").init();
connectionProps.setProperty(serviceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, EJB_ENDPOINT);
connectionProps.setProperty(serviceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL, serviceClientFactoryProperties.DSC_EJB_PROTOCOL);
connectionProps.setProperty(serviceClientFactoryProperties.DSC_SERVER_TYPE, "Jboss");
connectionProps.setProperty(serviceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
connectionProps.setProperty(serviceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");

// Initialize ServiceClientFactory with serviceClientFactoryProperties
myFactory = CreateObject("java","com.adobe.idp.dsc.clientsdk.ServiceClientFactory").createInstance(connectionProps);

// Initialize OutputClient with ServiceClientFactory properties
formsClient = CreateObject("java","com.adobe.livecycle.formsservice.client.FormsServiceClient").init(myFactory);

// Initialize FileInputStream with fileInput Variable
inXML_FileInputStream = CreateObject("java","java.io.FileInputStream").init(inXML);

// Set inPDF Document
inXML = CreateObject("java","com.adobe.idp.Document").init(inXML_FileInputStream);

PDFFormRenderSpec = CreateObject("java","com.adobe.livecycle.formsservice.client.PDFFormRenderSpec").init();
PDFVersion = CreateObject("java","com.adobe.livecycle.formsservice.client.PDFVersion");
PDFFormRenderSpec.setPDFVersion(PDFVersion.PDFVersion_1_5);

// Create URLSpec Object
URLSpec = CreateObject("java","com.adobe.livecycle.formsservice.client.URLSpec").init();
URLSpec.setApplicationWebRoot(applicationWebRoot);
URLSpec.setContentRootURI(contentRootURI);
URLSpec.setTargetURL(targetURL);

// Initiate The renderPDFForm Method
FormsResult = formsClient.renderPDFForm(inXDP,inXML,PDFFormRenderSpec,URLSpec,JavaCast( "null", "" ));

// Set outPDF Document For Result Handling
FormsResultPDF = FormsResult.getOutputContent();

// Initialize FileOutputStream with fileOutput Variable
fileOutputStream = CreateObject("java","java.io.File").init(outPDF);

FormsResultPDF.copyToFile(fileOutputStream);
</cfscript>

You can also download the source here Download Source