Quick Start (SwaRef): Deploying LiveCycle Applications using the web service API

The following Java code example imports an application based on an existing LCA file named EncryptDocument.lca. (See Deploying LiveCycle Applications.)

/** 
    * Ensure that you create Java proxy files that consume 
    * the Assembler services  WSDL. You can use JAX-WS to create 
    * the proxy Java files.   
    *    
    * For information, see "Invoking LiveCycle using SwaRef" in Programming with LiveCycle.   
    */ 
 
import javax.activation.DataHandler; 
import javax.activation.FileDataSource; 
import javax.xml.ws.BindingProvider; 
import com.adobe.idp.services.*; 
 
public class DeployApplicationSwaRef { 
    public static void main(String[] args){ 
         
        try{ 
            //Create an AssemblerServiceService object 
            ApplicationManagerService appManager = new ApplicationManagerService(); 
            ApplicationManager appManagerClient = appManager.getApplicationManager(); 
             
            //Set connection values required to invoke LiveCycle 
            String url = "http://hiro-xp:8080/soap/services/ApplicationManager?blob=swaRef"; 
            String username = "administrator"; 
            String password = "password"; 
            ((BindingProvider) appManagerClient).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); 
            ((BindingProvider) appManagerClient).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username); 
            ((BindingProvider) appManagerClient).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password); 
             
            //Get the LiveCycle application to deploy  
               String path = "C:\\Adobe\EncryptDocument.lca"; 
            FileDataSource ds = new FileDataSource(path);  
            DataHandler handler = new DataHandler(ds); 
            BLOB lcApp = new BLOB(); 
            lcApp.setSwaRef(handler); 
         
            //Import the application into the production server 
            ApplicationStatus appStatus = appManagerClient.importApplicationArchiveDocument(lcApp); 
            int status = appStatus.getStatusCode(); 
             
            //Determine if the application was successfully deployed 
            if (status==1) 
                    System.out.println("The application was successfully deployed"); 
            else 
                    System.out.println("The application was not successfully deployed. The status is "+status); 
        } 
        catch(Exception e) 
        { 
            e.printStackTrace(); 
        } 
    } 
} 

// Ethnio survey code removed