Skip to content

Sending Binary messages via REST


This sample demonstrates how to make RESTful service calls that contain binary data to Neuron. A REST client sends a jpg file to Neuron, which in turn saves the image to the file system.

The ESB Configuration contains a Process named Publish Image which demonstrates using some of the properties available when a REST request is received. This process checks for the source of the message. If the message was sent from a RESTful client, then the message routed to a file adapter endpoint to save the jpg to the file system. The process retrieves the image filename from the MessageHeader.LocalPath message property and uses the value to set the filename the file adapter will use when saving the file. If the message was received from the file system, it is routed to a RESTful service. For this route, the process retrieves the filename from the file adapter message properties and uses it to set the LocalPath message property. The process also sets the Method, Content-Type and WebBodyFormatMessageProperty property.


This sample uses the same Neuron solution as the other five REST samples. The solution contains five processes. This sample utilizes the “Publish Image” process, the service endpoints named “ImageClientConnector” and “ImageServiceConnector”, and the File Adapter endpoints “ImageFileSubscriberEndpoint” and “ImageFilePublisherEndpoint”.

Running the Sample

Open the Sample

To open this sample, see the topic Using the Neuron Samples and select the REST Client and Service with Binary Payloads sample.

Setup Instructions

Before running this sample, follow these instructions:

  1. In the Visual Studio project that opens, build the entire solution.
  2. Using the Neuron ESB Explorer, verify the Folder Path in the File Adapter Endpoints ImageFilePublisherEndpoint and ImageFileSubscriberEndpoint. If necessary, change the path to a valid location.
Note: This sample does not use the MessageData database. Any errors that occur in the Neuron Event Log relating to the MessageData database should not affect the running of the sample.

Run Instructions

Receiving Binary Data

  1. Start the ImageRESTClient project from Samples\Services\RESTServices\ImageREST\ImageRESTClient\bin\Debug\ImageRESTClient.exe
  2. In the ImageRESTClient console window, press Enter to start sending messages to Neuron.
ImageRESTClient console window
  1. As the sample runs, the client sends an image to the service and displays the HTTP response code.
HTTP response code
  1. The Neuron file adapter endpoint will save the image to the folder Samples\Services\RESTServices\ImageREST\Out.
  2. When the client completes, press <ENTER> in the client console to close the application.

Sending Binary Data

  1. Start the REST Service from Samples\Services\RESTServices\ImageREST\ImageRESTService\bin\Debug\ImageRESTService.exe
  1. Using Windows Explorer, navigate to Samples\Services\RESTServices\ImageREST and copy the file Neuron.jpg.
  2. Navigate to the “In” folder and paste the file. The file should disappear shortly once the file adapter retrieves it.
  3. The console window will display a notification when it receives the file, and the service will write the image to the folder Samples\Services\RESTServices\ImageREST\Out.
Was this article helpful?
Dislike 0
Previous: JSON Serialization/Deserialization
Next: Exposing an Adapter via RESTful Services