Oracle® Workspaces Web Services Application Developer's Guide 10g Release 1 (10.1.2.2) Part Number B28207-01 |
|
|
View PDF |
The Inbox service allows you to create, retrieve, and delete messages or threads within an inbox resource.
The following sample posts a message to the workspace's inbox:
Example 13-1 InboxServiceSample.java
package oracle.sample.workspaces.ws; import java.rmi.RemoteException; import javax.xml.rpc.ServiceException; import oracle.workspaces.ws.AuthenticationService; import oracle.workspaces.ws.HomeService; import oracle.workspaces.ws.InboxService; import oracle.workspaces.ws.InboxServiceServiceLocator; import oracle.workspaces.ws.InboxServiceSoapBindingStub; import oracle.workspaces.ws.beans.MessageDefinition; import oracle.workspaces.ws.beans.MessageItem; import oracle.workspaces.ws.beans.WorkspaceItem; import oracle.workspaces.ws.exceptions.CwWSException; import org.apache.axis.transport.http.HTTPConstants; public class InboxServiceSample { public static InboxService configureInboxService( String szAuthCookie) throws ServiceException { InboxServiceServiceLocator issl = new InboxServiceServiceLocator(); InboxService iService = issl.getInboxService(); ((InboxServiceSoapBindingStub)iService). setMaintainSession(true); ((javax.xml.rpc.Stub)iService). _setProperty(HTTPConstants.HEADER_COOKIE, szAuthCookie); return iService; } public static MessageItem postMessage( InboxService szInboxService, String szWorkspaceID ) throws RemoteException, CwWSException { MessageDefinition msgDefn1 = new MessageDefinition(); msgDefn1.setContentType("text/plain"); msgDefn1.setSubject("Mail message subject"); msgDefn1.setText("This is the first message to this email inbox"); return szInboxService.createMessage( szWorkspaceID, null, // No thread specified msgDefn1, null); // No attributes are to be retrieved from message } 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 InboxService and set authentication cookie InboxService myInboxService = InboxServiceSample.configureInboxService(authCookie); // Retrieve HomeService and set authentication cookie HomeService myHomeService = HomeServiceSample.configureHomeService(authCookie); // Create new workspace (or retrieve it if it already exists) WorkspaceItem myWorkspace = HomeServiceSample.createOrRetrieveWorkspace( myHomeService, "NewWorkspace", "My New Workspace", "Description of My New Workspace", "WRITER", "ENABLED"); System.out.println("Retrieved or created workspace"); // Create a message in the inbox resource of the // workspace InboxServiceSample.postMessage( myInboxService, myWorkspace.getWorkspaceUid()); System.out.println("Posted message"); myAuthenticationService.logout(); } catch (CwWSException cwwse) { System.out.println("CwWSException caught: " + cwwse.toString()); cwwse.printStackTrace(); } catch (Exception e) { System.out.println("Exception caught: " + e.toString()); } } }