API Quick Starts (Code Examples) > Invocation API Quick Starts > Quick Start: Invoking a service using Axis-generated files that use Base64 encoding

Quick Start: Invoking a service using Axis-generated files that use Base64 encoding
The following Java code example invokes a process named EncryptDocument using Axis-generated files that use Base64 encoding. (See Invoking LiveCycle ES using Base64 Encoding.)
An unsecured PDF document based on a PDF file named map.pdf is passed to the LiveCycle ES process. The process returns a password-encrypted PDF document that is saved as a PDF file named mapEncrypt.pdf.
/*
 * This Java Quick Start uses axis generated Java files and
 * base64 encoding.)
 * For complete details,
 * see "Invoking LiveCycle ES using Base64 Encoding" in 
 * Programming with LiveCycle ES
 */
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import com.adobe.idp.services.BLOB;
import com.adobe.idp.services.EncryptDocument;
import com.adobe.idp.services.EncryptDocumentServiceLocator;
 
public class InvokeDocumentEncryptBase64 {
public static void main(String[] args) {
		
		try{
		
			String pdfFile = "C:\\Adobe\\map.pdf";
            String encryptedPDF = "C:\\Adobe\\mapEncrypt.pdf";
            
			//create a service locator
			EncryptDocumentServiceLocator locate = new EncryptDocumentServiceLocator();
 
			//specify the service target URL and object type
			EncryptDocument encryptionClient = locate.getEncryptDocument();
			
			//Use the binding stub with the locator
			((javax.xml.rpc.Stub)encryptionClient)._setProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY, "administrator");
			((javax.xml.rpc.Stub)encryptionClient)._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY, "password");
						
		 	//Reference the PDF document to pass to the EncrptDocuemnt process
		 	FileInputStream file = new FileInputStream(pdfFile);
		 	
		 	//Create a byte array to store the PDF document
		 	int len = file.available();
		 	byte [] myByteArray = new byte[len];
		 	int i = 0;
		 	while (i < len) {
		 		  i += file.read(myByteArray, i, len);
		 	}
		 						
			//Create a BLOB object and populate it with the byte array
			BLOB inDoc = new BLOB();
			inDoc.setBinaryData(myByteArray);
			
			//Invoke the EncryptDocument process
			BLOB outDoc = encryptionClient.invoke(inDoc);
			
			//Populate a byte array with the encrypted PDF document
			byte[] myFile = outDoc.getBinaryData();
			
			//Create a File object
			File outFile = new File(encryptedPDF);
			
			//Create a FileOutputStream object.
			FileOutputStream myFileW = new FileOutputStream(outFile);
			
			//Call the FileOutputStream object's write method and pass the pdf data
			myFileW.write(myFile);
			
			//Close the FileOutputStream object
			myFileW.close();
			
			
	}catch (Exception e) {
			 e.printStackTrace();
			}	
}
 
}
 

API Quick Starts (Code Examples) > Invocation API Quick Starts > Quick Start: Invoking a service using Axis-generated files that use Base64 encoding

Programming with LiveCycle ES (LiveDocs)
Adobe LiveCycle ES Update 1

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/000010.html