Oracle® Workspaces Web Services Application Developer's Guide 10g Release 1 (10.1.2.2) Part Number B28207-01 |
|
|
View PDF |
The Template service allows users with application administrator role to create, retrieve, delete, and store workspace templates.
A template is an XML document that is used to create new workspaces with some predefined settings and content. See "Developing Workspace Templates with XML" in Oracle Workspaces Application Developer's Guide for more information.
The following sample outputs information about each workspace template stored in Oracle Workspaces:
Example 16-1 TemplateServiceSample.java
package oracle.sample.workspaces.ws; import java.rmi.RemoteException; import javax.xml.rpc.ServiceException; import oracle.workspaces.ws.AuthenticationService; import oracle.workspaces.ws.TemplateService; import oracle.workspaces.ws.TemplateServiceServiceLocator; import oracle.workspaces.ws.TemplateServiceSoapBindingStub; import oracle.workspaces.ws.beans.WorkspaceTemplateItem; import oracle.workspaces.ws.exceptions.CwWSException; import org.apache.axis.transport.http.HTTPConstants; public class TemplateServiceSample { public static TemplateService configureTemplateService( String szAuthCookie) throws ServiceException { TemplateServiceServiceLocator tssl = new TemplateServiceServiceLocator(); TemplateService tService = tssl.getTemplateService(); ((TemplateServiceSoapBindingStub)tService). setMaintainSession(true); ((javax.xml.rpc.Stub) tService). _setProperty(HTTPConstants.HEADER_COOKIE, szAuthCookie); return tService; } public static WorkspaceTemplateItem[] listTemplates( TemplateService szTemplateService) throws RemoteException, CwWSException { // Retrieve all workspace templates stored in Oracle // Workspaces, and output information about each of them WorkspaceTemplateItem[] wspcItem = szTemplateService.listWorkspaceTemplates(); if (wspcItem == null) { System.out.println("No templates were found"); } else { for (int i =0; i < wspcItem.length; i++) { System.out.println("Template #" + i + ":"); System.out.println("Created by: " + wspcItem[i].getTemplateCreatedBy()); System.out.println("Name: " + wspcItem[i].getTemplateName()); System.out.println("Web UI URI: " + wspcItem[i].getWebUIUrl()); } } return wspcItem; } public static void main(String[] args) { try { // Get authentication cookie AuthenticationService myAuthenticationService = AuthenticationSample.configureAuthenticationService( "rg4", "welcome1"); String authCookie = AuthenticationSample.getAuthenticationCookie (myAuthenticationService); System.out.println("Retrieved authentication cookie : " + authCookie); // Get TemplateService and set authentication cookie TemplateService myTemplateService = TemplateServiceSample.configureTemplateService(authCookie); // Output information about each template TemplateServiceSample.listTemplates(myTemplateService); myAuthenticationService.logout(); } catch (CwWSException cwwse) { System.out.println("CwWSException caught: " + cwwse.getMessage()); cwwse.printStackTrace(); } catch (Exception e) { System.out.println("Exception caught: " + e.toString()); } } }