Quick Start (Java SWAref): Disassembling a PDF document using the web service API

The following Java code example disassembles a PDF document named AssemblerResultPDF.pdf. Notice that the name of the DDX document is shell_disassemble.xml. Each disassembled PDF document is named ResultPDF[Number].pdf. That is, the first disassembled PDF document is named ResultPDF1.pdf. For information about the shell_disassemble.xml DDX document used in this code example, see Programmatically Disassembling 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   
import java.io.*; 
import java.util.*; 
import javax.activation.DataHandler; 
import javax.activation.FileDataSource; 
import javax.xml.ws.BindingProvider; 
import org.apache.xml.xml_soap.*; 
import com.adobe.idp.services.*; 
public class DisassemblePDFSWAref { 
    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); 
            //Reference the DDX required to disassemble a PDF document         
            String path1 = "C:\\shell_disassemble.xml"; 
            FileDataSource ds1 = new FileDataSource(path1);  
            DataHandler handler1 = new DataHandler(ds1); 
            BLOB ddxDoc = new BLOB(); 
            //Reference the PDF document to disassemble  
            String path2 = "C:\\AssemblerResultPDF.pdf"; 
            FileDataSource ds2 = new FileDataSource(path2);  
            DataHandler handler2 = new DataHandler(ds2); 
            BLOB inDoc = new BLOB(); 
               //Create the map containing input files 
            MyMapOfXsdStringToXsdAnyType inputMap = new MyMapOfXsdStringToXsdAnyType(); 
            List<MyMapOfXsdStringToXsdAnyTypeItem> inputMapItemList = inputMap.getItem(); 
            MyMapOfXsdStringToXsdAnyTypeItem inputDocItem = new MyMapOfXsdStringToXsdAnyTypeItem(); 
               //Create an AssemblerOptionsSpec object 
               AssemblerOptionSpec assemblerSpec = new AssemblerOptionSpec(); 
               //Send the request to the Assembler Service 
               AssemblerResult result = assembClient.invoke(ddxDoc, inputMap, assemblerSpec); 
               //Extract the newly created PDF documents from the returned map 
               List<MapItem> mapResult = result.getDocuments().getItem(); 
            Iterator<MapItem> rit = mapResult.iterator(); 
            int i = 0; 
                MapItem resultItem = rit.next(); 
                   //Determine the data type of the map item element 
                   if (resultItem.getValue() instanceof BLOB) 
                       //Save the disassembled PDF document as  
                       //a PDF file 
         File f = new File("C:\\ResultPDF"+i+".pdf"); 
                    BLOB outBlob = (BLOB)resultItem.getValue(); 
                    DataHandler handler3 = outBlob.getSwaRef(); 
                    //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); 
            if (i > 0) 
                System.out.println("The PDF document was disassembled into "+i+" PDF documents."); 
                System.out.println("The PDF document was not disassembled."); 
        catch(Exception e) 

// Ethnio survey code removed