Creating Data Services Server Artifacts
The following sections describe how to use WSO2 Developer Studio to create artifacts for Data Services Server. For more information on the details of configuring data service artifacts, including namespaces, service groups, and data source types, see the Data Service Server documentation.Â
The following section describes how to use WSO2 Developer Studio to add multiple data services to a single Data Service project.
Creating a data service project
- You can either use the link on the dashboard (click Developer Studio -> Open Dashboard) as shown below or use the File-> New -> Other -> Data Service Project option.
 - On the window that appears, specify a project name.Â
 - If you want to customize the Maven options (such as including parent POM information in the file from another project in this workspace), click Next and specify the options.
- Click Finish.
Creating a data service
A data service provides a Web service interface to access data that is stored in relational databases, CSV files, Microsoft Excel sheets, Google spreadsheets, and more. You can create a new data service or import an existing data service from a data service descriptor (DBS) file. Â
Creating a new data service
Follow these steps to create a new data service. Alternatively, you can import an existing data service.
- You can either use the Data Service Project link on the dashboard (click Developer Studio -> Open Dashboard) or right-click on the Data Service project and click New -> Data Service.Â
- Select Create New Data Service and click Next.
- Type unique names for the project and data service.
- Optionally, specify the service group, namespace, description, location, and working set for this data service.
- Click Next and specify a unique ID for the data source.
- Specify the type of data source you are creating, and then configure the properties that appear for that type. For details on configuring various data source types, see Creating Using Various Data Sources in the Data Services Server documentation.
- A Maven POM file will be generated automatically for this project. If you want to customize the Maven options (such as including parent POM information in the file from another project in this workspace), click Next and specify the options.
- Click Finish. The data service is created, and the data service is open in the editor. You can now right-click the data service in the outline and add queries, operations, additional data sources, and so on, or click the Source view to add components using XML. Â
Importing a data service
Follow these steps to import an existing data service from a data service descriptor (DBS) file. Alternatively, you can create a new data service.
- You can either use the Data Service link on the dashboard (click Developer Studio -> Open Dashboard) or right-click on the Data Service project and click New -> Data Service.Â
- Select Import Data Service and click Next.
- Specify the data service descriptor (DBS) file by typing its full pathname or clicking Browse and navigating to the file.
- Optionally specify the location and working sets for this project.Â
- A Maven POM file will be generated automatically for this project. If you want to customize the Maven options (such as including parent POM information in the file from another project in this workspace), click Next and specify the options.
- Click Finish. The data service is created, and the data service is open in the editor. You can now right-click the data service in the outline and add queries, operations, additional data sources, and so on, or click the Source view to add components using XML.
Adding multiple data services
It is possible to add multiple data services to a Data Service project by following the steps described above. The project structure will be as follows:
Â
Creating a custom validator
An input validator allows a data service to validate the input parameters in a request and stop the execution of the request if the input doesn’t meet the required criteria. In addition to the default validators provided by Data Service Server, you can create your own custom validators by creating a Java class that implements the org.wso2.carbon.dataservices.core.validation.Validator
interface. You can create a new custom validator or import an existing validator project. Â
Creating a new custom validator
Follow these steps to create a new custom validator. Alternatively, you can import an existing validator project.
- You can either use the Data Services Validator Project link on the dashboard (click Developer Studio -> Open Dashboard) or click File-> New -> Other -> Data Services Validator Project option.Â
- Select Create New Data Services Validator Project and click Next.
- Type a unique name for the project and specify the package and class name for this validator.
- Optionally, specify the location and working set for this project.
- A Maven POM file will be generated automatically for this project. If you want to customize the Maven options (such as including parent POM information in the file from another project in this workspace), click Next and specify the options.
- Click Finish. The project is created, and the new validator class is open in the editor, where you can add your validation logic. Â
Importing a validator project
Follow these steps to import an existing custom validator project. Alternatively, you can create a new custom validator.
- You can either use the Data Services Validator Project link on the dashboard (click Developer Studio -> Open Dashboard) or click File-> New -> Other -> Data Services Validator Project option.Â
- Select Import Project From Workspace and click Next.
- Select the existing validator project, and optionally specify the location and working sets for the new project.Â
- A Maven POM file will be generated automatically for this project. If you want to customize the Maven options (such as including parent POM information in the file from another project in this workspace), click Next and specify the options.
- Click Finish. The project is imported, and the validator class is open in the editor, where you can modify the validation logic as needed.
Packaging artifacts
You can use a Composite Application project to pack the created data services and then export it as a .car
file, which can be deployed to the Data Services Server. For information on deploying the artifacts, see Packaging Artifacts Into Deployable Archives.