This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Exposing a Web Resource as a Data Service
This tutorial will guide you on how to expose a web resource as a data service using the ESB profile of WSO2 Enterprise Integrator (WSO2 EI). You can create a data service that can fetch selected data from a web resource and display the data in XML, JSON or RDF form.
Follow the instructions below. Also, see the samples in Data Integration Samples.
Creating a data service
Now, let's start creating the data service from scratch:
Log in to the management console of ESB profile of WSO2 EI using the following URL on your browser: "https://localhost:9443/carbon/".
Click Create under the Data Service menu to open the Create Data Service window.
Enter the following data service name.
Leave the default values for the other fields.
Click Next to go to the Datasources screen.
Connecting to the datasource
You can add a web resource as the datasource by following the steps given below.
Click Add New Datasource and enter the following details:
Save the datasource.
Click Next to go to the Queries screen.
Creating a query to GET data
Now let's start writing a query for getting data from the web resource. The query will specify the data that should be fetched by this query, and the format that should be used to display the data.
Click Add New Query and enter the following details:
Define Output Mapping: Now, let's specify how the data fetched from the datasource should be displayed in the output. We will create output mappings for the following data in the web resource: Title and Description.
Start by giving the following details:
Click Add New Output Mapping to start creating the output mapping for the Title field.
Click Add to save the output mapping.
Now, add another output mapping for the Description column.
You will now have the following output mappings listed for the webquery query:
Click Next to go to the Operations screen.
Creating a SOAP operation to invoke the query
To invoke the query, you need to define an operation.
Click Add New Operation and enter the following information.
Save the operation.
You can now invoke the data service query using SOAP.
Creating a REST resource to invoke the query
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.
Click Add New Resource and enter the following information.
Save the resource.
You can now invoke the data service query using REST.
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.
Go to the Deployed Services screen.
Click the Try this service link for the WebResource data service. The TryIt Tool will open with the data service.
Select the GetResource operation and click Send.
The response will be published.
Invoking your data service using REST
You can send an HTTP GET request to invoke the data service using cURL as shown below.
curl -X GET http://localhost:8280/services/WebResource.HTTPEndpoint/AppInfoThis will return the response in XML.