For applications that do not externalize input or output data, request models must be created and populated, and response data must be explicitly handled. In this case, do the following:
1 Obtain a request model.
2 Populate the request model with data.
3 Initialize the service.
4 Carry out the request.
5 Obtain the response model.
6 Use response data.
The code is as follows:
LDAPLookupRequest request = new LDAPLookupRequest(); request.setName("cn=John Doe,ou=Finance,o=XYZ Corp,c=US"); LDAPService service = (LDAPService)Service.readObject("aLdapService"); service.initialize(); LDAPResponse response = service.performRequest(request);
(At this point the application can read and use the result of the request from the response object.)
The following is a complete example of utilizing the LDAP Access Service using no externalized data:
LDAPService aService = null; LDAPRequest request = null; LDAPResponse = null; /* configure the service */ aService.setAuthenticationCredentials("password"); aService.setAuthenticationMethod("simple"); aService.setAuthenticationPrincipal("cn=root"); aService.setProviderFactory("com.sun.jndi.ldap.LdapCtxFactory"); aService.setProviderUrl("ldap://localhost:389"); /* obtain request model */ request = new LDAPLookupRequest(); /* set input data */ request.setName("cn=Ted Geisel,ou=Finance,o=XYZ Corp,c=US"); /* utilize the service */ aService.initialize(); response = aService.performRequest(request);