Skip to content

Exposing an Adapter via RESTful Services


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:

  1. Open the SQL Script located at Samples\Processes\CreateSampleDB.sql in SQL Server Management Studio.
  2. Execute the SQL Script to create the MessageData database.
Note: You may have to adjust the security settings of the SQL Database to provide the appropriate permissions to the service account used by the Neuron ESB Service.
Note: After adding the SQL Database and adjusting permissions, you will need to restart the three SQL Adapter Endpoints in the Neuron Explorer by navigating to Activity->Endpoint Health, click Start Monitoring, and individually select and right-click on each stopped Adapter endpoint and select Restart Service.
  1. In the Visual Studio project that opens, build the entire solution.
  2. Verify the connection strings in the SQL Adapter Endpoints are configured to connect to the database created in steps 1 & 2.

Run Instructions

  1. In Visual Studio, press F5 to start the RESTtoSQLClient project.
  2. In the RESTtoSQLClient console window, press Enter to start sending messages to Neuron.
  1. As the sample runs, the client sends a message to the service and displays the response.
  1. When the client completes, press <ENTER> in the client console to close the application.
Was this article helpful?
Dislike 0
Previous: Sending Binary messages via REST
Next: SOAP-to-REST Service Mediation