Tuscany SCA Native Samples - REST Customer Sample

This is a very simple sample to show how to use the SCA REST binding to implement a resource management service and make resources available through HTTP.

The REST Customer sample requires the following extensions:

Please follow the documentation to ensure you have these extensions built and installed on your system

There are three sub-projects in this workspace:

  • sample.customer
    This contains the source code and SCDL artifacts for the SCA component implementing the Customer resource management service.
  • sample.customer.restclient
    A sample REST client which shows how to create, update, retrieve, and delete Customer resources.
  • httpserver
    This contains a minimal configuration for the Apache HTTP server used to host the REST service as well as scripts to start and stop the server.

Additionally, there is the sample.customer.app.composite file. This describes the configuration of the SCA Customer composite deployed to the SCA runtime.

Building the REST Customer sample on Linux and Mac OS X

If using the binary distribution the samples are built and installed in <tuscany_sca_install_dir>/samples - go directly to Running the samples on Linux and Mac OS X.

  1. The following environment variables are required:
    • TUSCANY_SCACPP=<path to installed Tuscany SCA>
    • TUSCANY_SDOCPP=<path to installed Tuscany SDO>
  2. As the REST Customer sample is based on Python scripts, a specific compilation step is not necessary - only deployment is required. Deploy the Python samples only with the following command sequence:
    • cd <tuscany_sca_install_dir>/samples
    • ./configure --enable-python --enable-cpp=no --prefix=$TUSCANY_SCACPP/samples
    • make install
    NOTE: If you don't provide the --prefix configure option, it will by default install into /usr/local/tuscany/sca/samples/RestCustomer

Running the REST Customer sample on Linux and Mac OS X

  1. The REST Customer sample requires the following extensions: Please follow the documentation to ensure you have these extensions built and installed on your system
  2. Start the Apache HTTPD server:
    1. The following environment variables are required:
      • TUSCANY_SCACPP=<path to installed Tuscany SCA>
      • TUSCANY_SDOCPP=<path to installed Tuscany SDO>
      • PYTHON_LIB=<path to the Python library>
        Note: If you are using a default installation of Python 2.5 this is usually /usr/lib
    2. cd <tuscany_sca_install_dir>/samples/RestCustomer/deploy/httpserver
    3. ./startserver.sh
      NOTE: Depending on your installation of Apache HTTPD you may need to log in as root before following these steps. If so, you may also need to uncomment the User and Group directives in the <tuscany_sca_install_dir>/samples/RestCustomer/deploy/httpserver/conf/httpd.conf file and set these to the appropriate username and group that the server should run as
  3. Run the client:
    1. The following environment variable is required:
      • TUSCANY_SCACPP=<path to installed Tuscany SCA>
      • TUSCANY_SDOCPP=<path to installed Tuscany SDO>
      • PYTHON_LIB=<path to the Python library>
        Note: If you are using a default installation of Python 2.5 this is usually /usr/lib
    2. cd <tuscany_sca_install_dir>/samples/RestCustomer/deploy/sample.customer.restclient
    3. ./runrestclient.sh

Building the REST Customer sample on Windows

If using the binary distribution the samples are built and installed in <tuscany_sca_install_dir>\samples - go directly to Running the samples on Windows.

  1. The following environment variables are required:
    • TUSCANY_SCACPP=<path to installed Tuscany SCA>
    • TUSCANY_SDOCPP=<path to installed Tuscany SDO>
  2. As this sample is based on Ruby scripts, a specific compilation step is not necessary - only deployment is required. Deploy the sample with the following commands:
    • cd <tuscany_sca_install_dir>\samples\RestCustomer
    • deploy.bat

Running the REST Customer sample on Windows

  • The REST Customer sample requires the following extensions: Please follow the documentation to ensure you have these extensions built and installed on your system
  • Start the Apache HTTPD server:
    1. The following environment variables are required:
      • TUSCANY_SCACPP=<path to installed Tuscany SCA>
      • TUSCANY_SDOCPP=<path to installed Tuscany SDO>
      • HTTPD_HOME=<path to installed Apache HTTPD server>
    2. cd <tuscany_sca_install_dir>\samples\RestCustomer\deploy\httpserver
    3. startserver.bat
  • Run the client:
    1. The following environment variables are required:
      • TUSCANY_SCACPP=<path to installed Tuscany SCA>
      • TUSCANY_SDOCPP=<path to installed Tuscany SDO>
      • LIBCURL_HOME=<path to installed libcurl libraries>
    2. cd <tuscany_sca_install_dir>\samples\RestCustomer\deploy\sample.customer.restclient
    3. runrestclient.bat
  • Getting Help

    The first place to look is at the Tuscany SCA FAQ at http://cwiki.apache.org/confluence/display/TUSCANY/Tuscany+SCA+-+FAQ

    Any problem with this release can be reported to the Tuscany mailing lists or create a JIRA issue at http://issues.apache.org/jira/browse/Tuscany.