Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This tutorial will guide you on how to expose data stored in Cassandra as a data serviceAlso, see the samples in Data Integration Samples.

...

...

  1. Click Add New Query and enter the following details:

    Query IDEnter getUsersbyID as the query ID.
    DatasourceSelect the datasource for which you are going to write a query. Select the Cassandra datasource that you created previously.
    SQL

    In this field, enter the SQL statement describing the data that should be retrieved from the Cassandra datasource.

    Code Block
    SELECT id, age, country, name FROM UsersKS.Users WHERE id = :id
  2. Click Generate Input Mapping to create the input mapping. The id is the input as shown below.


  3. Edit the id column and change the the SQL Type to UUID.
  4. Save the mapping and click Main Configuration to return to the query.
  5. Click Generate Response to create the output mapping. This defines how the employee details retrieved from the datasource will be presented in the result. Note that, by default, the output type is XML. 

  6. Save the query.
  7. Click Next to open the Operations screen.

...

  1. Click Add New Operation and enter the following information.

    Operation NameaddUsersOp
    Query IDaddUsers
  2. Save the operation.
  3. Click Add New Operation and enter the following information.

    Operation NamegetUsersbyIDopgetUsersbyIDOp
    Query IDgetUsersbyID
  4. Save the operation.

...

Now, let's create REST resources to invoke the query created above. Alternatively, you can create SOAP operations to invoke the queries. See the previous section for instructions.

  1. Click Add New Resource and enter the following information.

    Resource Pathusers
    Resource MethodPOST
    Query ID addUsers
  2. Save the resource.
  3. Click Add New Resource and enter the following information.

    Resource Pathusers/{id}
    Resource MethodGET
    Query IDgetUsersbyID
  4. Save the resource.

...

Finish creating the data service

Once you have defined the operation, click Finish to complete the data service creation process. You will now be taken to the Deployed Services screen, which shows all the data services deployed on the server.

Invoking your data service using SOAP

You can try the data service you created by using the TryIt tool that is in your product by default. 

  1. Go to the Deployed Services screen.
  2. Click the Try this service link for the Cassandra data service. The TryIt Tool will open with the data service.

Post new data

  1. Select the addUsersOp operation you created earlier. 
  2. You need to provide the user details. Be sure to enter a UUID value as the user ID.

  3. Click Send.

The data is now added to the database.

Get data

  1. Select the getUsersbyIDop getUsersbyIDOp operation you created earlier. 
  2. Enter the UUID value that you entered as the user's ID previously.
  3. Click Send to see the details of the user you added previously.

...