CORBA Web Server Assignment Part 1

This assignment is a follow-on to the socket assignment. Rather than using C, sockets, and HTTP, you will implement a simple Web client and server using CORBA and IIOP. Client applications can use this service to download and display files from a CORBA server on the network. In this service, CORBA remote operations, rather than socket calls, are used to download the file from a particular machine.


Design and Implementation Issues

CORBA IDL Interface

The CORBA Web server will be designed as a client/server pair using the following IDL specification:
// IDL schema definition for Web server interface.
interface Web_Server
{
  typedef sequence<octet> Content_Type;
  struct Metadata_Type 
  {
    // Status of the <get> operation.  These
    // values should map onto the normal HTTP
    // status values, e.g., 200 means success, 404
    // means "file not found," etc.
    short status_;

    // Modification date.
    string modification_date_;
    
    // Type of content.
    string content_type_;
  };

  // Download the <contents> associated with <pathname>.
  // The <metadata> reports information about the <contents>.
  void get (in string pathname,
            out Content_Type contents,
            out Metadata_Type metadata);
};
The get operation is passed an in parameter pathname, which is equivalent to the pathname you passed to the Web server in assignment 1. The get operation returns a pair of out parameters. The first one is an octet sequence that contains the contents identified by the pathname. The second is a struct containing metadata that describes certain information, such as the MIME type and return status, about the contents. If an error occurs, the status_ field of metadata will contain a non-success value and the contents parameter will be undefined.

You will use a CORBA IDL compiler to translate this specification into client-side stubs and server-side skeletons. The client application (which you must write) will use the stubs as a proxy to request the server to download the content. In addition, you must also write the server, which implements the get operation that downloads content to the client.


Server Functionality

On the server-side, you'll need to define a class that inherits from the skeleton generated by the IDL compiler. The C++ class for this should look something like the following:

// Implement the Web_Server interface.

class Web_Server_i : virtual public POA_Web_Server
{
public:
  // Download the <contents> associated with <pathname>.
  // The <metadata> reports information about the <contents>.
  virtual void get (const char *pathname,
                    Content_Type_out contents,
                    Metadata_Type_out metadata)
    throw (CORBA::SystemException);

};
To implement the get operation you'll need to use OS filesystem APIs, such as open(2), close(2), and read(2). I recommend that you check the UNIX manual pages for more details on using these functions.

In addition, you'll need to implement a main function that defines an instance of Web_Server_i, obtains and activates the RootPOA and then calls the ORB's run method to start its event loop.

To make your life easy, the server should write its IOR to a file before it calls the ORB's run method (later, we'll use more advanced techniques, such as a Naming Service). Thus, when your server is started, you should create a file that contains something like the following:

iioploc://1.1@newport.ece.uci.edu:10015/P35ad159600081a38/\0\1server
if you use the -ORBObjRefStyle URL IOR format or
IOR:000000000000001649444c3a43756269745...
if you use the -ORBObjRefStyle IOR IOR format. For more information on these options, please see the TAO online options documentation.


Client Functionality

The simple WWW client program should do the following activities:
  1. From the command-line, read the name of the pathname you want to download and the name of the file that contains the IOR discussed above. When the client starts up, it will read the contents of this file into a string and use the string_to_object() method to convert the string into an object reference. This object reference will then be downcast via _narrow() to an object reference for the Web_Server interface. At this point, it can call the get operation via the object reference to download the file.

  2. When get returns successfully, write the contents into a temporary file created in your WWW cache (e.g., /tmp/yourloginname) on the local host [creat,read/write]. Then, spawn an external viewer [fork/exec] to display the file. You can determine the type of viewer to spawn by examining the the content_type_ metadata returned by the server.
The client should simply print out the appropriate exception and exit with a return status of 1 if anything fails to work properly. If everything works correctly, the program should exit with a return status of 0.


Learning and Using CORBA

We will be using the TAO CORBA Object Request Broker (ORB) implementation. Please see the online help for information on how to setup your TAO development environment on ECE's computing system.


Concluding Remarks

This first CORBA assignment is relatively simple. However, it will illustrate the basic skills required to become adept at distributed object computing with CORBA. Subsequent assignments will build on this assignment, so make sure you get it working correctly.


Back to ECE 255 home page.