Exposing an Adapter via RESTful Services
- Home
- Neuron ESB
- Development
- Samples and Walkthroughs
- Services (Samples)
- REST Samples
- Exposing an Adapter via RESTful Services
Overview
This sample demonstrates how to use Neuron to expose a SQL database as a RESTful service. The sample contains a REST client, ESB Configuration and a SQL database.
The ESB Configuration contains a Process named REST to SQL that implements a pattern for routing REST requests based on the HTTP method (GET, POST, etc). This process routes POST requests to SQL Creates, DELETE request to SQL Deletes and GET requests to SQL Reads. The process then sets the message Action property appropriately and transforms the REST request into the correct SQL adapter message format. The message is published to the bus and the response is transformed into the correct format for the REST response. If the request is not a GET, POST or DELETE, the process returns a 400 Bad Request response. The sample client application attempts to send an UPDATE and will receive that response.
Running the Sample
Open the Sample
To open this sample, see the topic Using the Neuron Samples and select the REST Client to SQL Server sample.
Setup Instructions
Before running this sample, follow these instructions:
- Open the SQL Script located at Samples\Processes\CreateSampleDB.sql in SQL Server Management Studio.
- Execute the SQL Script to create the MessageData database.
- In the Visual Studio project that opens, build the entire solution.
- Verify the connection strings in the SQL Adapter Endpoints are configured to connect to the database created in steps 1 & 2.
Run Instructions
- In Visual Studio, press F5 to start the RESTtoSQLClient project.
- In the RESTtoSQLClient console window, press Enter to start sending messages to Neuron.
- As the sample runs, the client sends a message to the service and displays the response.
- When the client completes, press <ENTER> in the client console to close the application.