Quick Start (SwaRef): Adding users using the web service API

The following Java web service code example adds a user named Wendy Blue to LiveCycle. (See Adding Users.)

/** 
    * Ensure that you create Java proxy files that  
    * are required to send a LiveCycle process  
    * an attachment using SwaRef. 
    *  
    * For information, see "Invoking LiveCycle using SwaRef" in Programming with LiveCycle.   
    */ 
import javax.xml.ws.BindingProvider; 
import com.adobe.idp.services.*; 
import java.util.*; 
 
public class AddUserSwaRef { 
     
    public static void main(String[] args) { 
        try  
        { 
            //Set connection values required to invoke LiveCycle using swaref 
            String url = "http://hiro-xp:8080/soap/services/DirectoryManagerService?blob=swaref"    ; 
            String username = "administrator"; 
            String password = "password"; 
             
            //Create a DirectoryManagerServiceService object 
            DirectoryManagerServiceService userManager = new DirectoryManagerServiceService();  
            DirectoryManagerService dmClient = userManager.getDirectoryManagerService(); 
             
             //Set authentication values 
            ((BindingProvider)dmClient).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); 
            ((BindingProvider)dmClient).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username); 
            ((BindingProvider)dmClient).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password); 
                       
            //Create a UserImpl object 
            UserImpl u = new UserImpl(); 
            u.setDomainName("DefaultDom");  
            u.setUserid("wblue");  
            u.setCanonicalName("wblue");  
            u.setPrincipalType("USER");  
            u.setGivenName("Wendy");  
            u.setFamilyName("Blue");  
            u.setDisabled(false); 
         
            //Add the User to LiveCycle 
            dmClient.createLocalUser(u,"password"); 
         
            //Verify that the user was added to LiveCycle 
            PrincipalSearchFilter psf = new PrincipalSearchFilter(); 
            psf.setUserId("wblue"); 
             
            //Create a List and iterate through the list             
            MyArrayOfPrincipal map = dmClient.findPrincipalsWithFilter(psf);  
            List users = map.getItem(); 
            Iterator<Object> pit = users.iterator(); 
            if(pit.hasNext()){ 
                User theUser = (User)pit.next(); 
                System.out.println("User ID: " + theUser.getUserid()); 
                System.out.println("User name: " + theUser.getGivenName() +" "+ theUser.getFamilyName()); 
                System.out.println("User Domain: " + theUser.getDomainName()); 
                System.out.println("is user disabled?: " + theUser.isDisabled()); 
            } 
         
        }catch (Exception e) { 
            e.printStackTrace(); 
        } 
    } 
} 

// Ethnio survey code removed