Quick Start (SwaRef): Searching for events using the web service API

The following web service Java code example searches for the create policy event. (See Searching for Events.)

/** 
    * Ensure that you create Java proxy files that consume 
    * the Rights Management 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.util.Iterator; 
import java.util.List; 
import javax.xml.ws.BindingProvider; 
import com.adobe.idp.services.*; 
 
public class SearchEventSwaRef { 
    public static void main(String[] args) { 
          try{ 
                //Setting configurations to retrieve the Web service 
                String url = "http://hiro-xp:8080/soap/services/RightsManagementService?blob=swaRef"; 
                String username = "administrator"; 
                String password = "password"; 
                 
                //Create the RightsManagementServiceService object 
                RightsManagementServiceService rightsManagementService = new RightsManagementServiceService(); 
                RightsManagementService rightsManagementClient = rightsManagementService.getRightsManagementService(); 
                 
                //Set connection properties required to invoke LiveCycle     
                ((BindingProvider) rightsManagementClient).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); 
                ((BindingProvider) rightsManagementClient).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username); 
                ((BindingProvider) rightsManagementClient).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password); 
             
                   //Create an EventSpec object 
                   EventSpec eventSpec = new EventSpec(); 
 
                   //Specify the POLICY_CREATE_EVENT 
                   eventSpec.setEventCode("3003"); 
     
                   //Search for the POLICY_CREATE_EVENT 
                   MyArrayOfXsdAnyType result = rightsManagementClient.searchForEvents(eventSpec, 100); 
 
                   //Specify the dates when this event occurred 
                   List<Object> resultList = result.getItem(); 
                   Iterator<Object> rit = resultList.iterator(); 
                   while (rit.hasNext()) 
                   { 
                       AuditSpec spec = (AuditSpec)rit.next(); 
                       System.out.println("Policy Created on " + spec.getTimestamp().getDate().toString()); 
                   } 
          }catch(Exception e) 
          { 
                 e.printStackTrace();  
          } 
    } 
} 
 

// Ethnio survey code removed