Quick Start (SwaRef): Assembling a non-interactive PDF document using the web service API

The following Java code example assembles a non-interactive PDF document. The interactive PDF document that is passed to the Assembler service is named Loan.pdf. Notice that the name of the DDX document is shell_XFA.xml. The non-interactive PDF document is saved as a PDF file named AssembleNonInteractivePDF.pdf. (See Assembling Non-Interactive PDF Documents.)

    * 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. 
    * The following XML represents the DDX document used in this quick start: 
    * <?xml version="1.0" encoding="UTF-8"?> 
    * <DDX xmlns="http://ns.adobe.com/DDX/1.0/"> 
    * <PDF result="out.pdf"> 
    *   <PDF source="inDoc"/> 
    *   <NoXFA/> 
    * </PDF> 
    * </DDX> 
import java.io.*; 
import javax.activation.DataHandler; 
import javax.activation.FileDataSource; 
import javax.xml.ws.BindingProvider; 
import com.adobe.idp.services.*; 
public class AssembleNonInteractiveSWAref { 
    public static void main(String[] args){ 
            //Create an AssemblerServiceService object 
            AssemblerServiceService assembler = new AssemblerServiceService(); 
            AssemblerService assembClient = assembler.getAssemblerService(); 
            //Set connection values required to invoke LiveCycle 
            String url = "http://hiro-xp:8080/soap/services/AssemblerService?blob=swaRef"; 
            String username = "administrator"; 
            String password = "password"; 
            ((BindingProvider) assembClient).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); 
            ((BindingProvider) assembClient).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username); 
            ((BindingProvider) assembClient).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password); 
            // Create BLOB objects that represents the input  
            String path = "C:\\shell_XFA.xml"; 
            FileDataSource ds = new FileDataSource(path);  
            DataHandler handler = new DataHandler(ds); 
            BLOB ddxDoc = new BLOB(); 
            String path2 = "C:\\Adobe\Loan.pdf"; 
            FileDataSource ds2 = new FileDataSource(path2);  
            DataHandler handler2 = new DataHandler(ds2); 
            BLOB LoanDoc = new BLOB(); 
            // Create an AssemblerOptionsSpec object 
            AssemblerOptionSpec assemblerSpec = new AssemblerOptionSpec(); 
            // Send the request to the Assembler Service 
            BLOB outDoc = assembClient.invokeOneDocument(ddxDoc,LoanDoc,assemblerSpec); 
            //Populate a byte array with BLOB data 
            DataHandler handler3 = outDoc.getSwaRef(); 
            //Create a new file containing the returned PDF document 
            File f = new File("C:\\AssembleNonInteractivePDF.pdf"); 
            //Get an InputStream from DataHandler and 
            //write to a file 
            InputStream inputStream = handler3.getInputStream(); 
            OutputStream out = new FileOutputStream(f); 
            //Iterate through the buffer 
            byte buf[] = new byte[1024]; 
            int len; 
            while ((len = inputStream.read(buf)) > 0) 
                out.write(buf, 0, len); 
            System.out.println("The non-interactive PDF document was assembled."); 
        catch(Exception e) 

// Ethnio survey code removed