Skip Headers
Oracle® Workspaces Web Services Application Developer's Guide
10g Release 1 (10.1.2.2)

Part Number B28207-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

13 Inbox Service

The Inbox service allows you to create, retrieve, and delete messages or threads within an inbox resource.

Example: Post Message to Inbox

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());
    }
  }
}