Quick Start (SwaRef): Retrieving signature field names using the web service API

The following Java web service code example retrieves the names of signature fields located in a PDF document named LoanSig.pdf. (See Retrieving Signature Field Names.)

/** 
    * Ensure that you create Java proxy files that consume 
    * the Signature services  WSDL. You can use JAX-WS to create 
    * the proxy Java files.   
    *  
    * If you are supplying a set of associated files, add the file name to the BLOB attribute. 
    * The create3DPDF service uses those file names to resolve references from the main assembly file. 
    *    
    * For information, see "Invoking LiveCycle using SwaRef" in Programming with LiveCycle.   
    */ 
import java.util.*; 
import java.io.*; 
import javax.activation.DataHandler; 
import javax.activation.FileDataSource; 
import javax.xml.ws.BindingProvider; 
 
import com.adobe.idp.services.*; 
 
 
public class GetSignatureFieldsSWAref { 
 
public static void main(String[] args) { 
    try 
    { 
        // Create a SignatureServiceService object 
        SignatureServiceService signatureService = new SignatureServiceService(); 
        SignatureService signatureClient =  signatureService.getSignatureservice(); 
         
        //Set connection settings 
        String url = "http://hiro-xp:8080/soap/services/signatureservice?blob=swaRef"; 
        String username = "administrator"; 
        String password = "password"; 
         
        ((BindingProvider) signatureClient).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); 
        ((BindingProvider) signatureClient).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username); 
        ((BindingProvider) signatureClient).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password); 
             
        //Set an input file as a BLOB         
        String path1 = "C:\\Adobe\LoanSig.pdf"; 
        FileDataSource ds1 = new FileDataSource(path1);  
        DataHandler handler1 = new DataHandler(ds1); 
        BLOB inDoc = new BLOB(); 
        inDoc.setSwaRef(handler1); 
         
        //Retrieve the name of the document's signature fields 
        MyArrayOfPDFSignatureField fieldNames = signatureClient.getSignatureFieldList(inDoc); 
 
        //Obtain the name of each signature field by iterating through the  
        //List object 
        List<PDFSignatureField> fieldNamesList = fieldNames.getItem(); 
        Iterator<PDFSignatureField> iter = fieldNamesList.iterator();  
        int i = 0 ;  
        String fieldName=""; 
        while (iter.hasNext()) {  
            PDFSignatureField signatureField = (PDFSignatureField)iter.next();  
            fieldName = signatureField.getName(); 
            System.out.println("The name of the signature field is " +fieldName);  
            i++; 
             } 
        } 
        catch (Exception ee) 
        { 
            ee.printStackTrace(); 
        } 
    } 
}

// Ethnio survey code removed