This sample demonstrates how to make RESTful service calls that use JSON serialization/deserialization through Neuron. The sample first demonstrates a Windows Communication Foundation (WCF) client calling a Neuron Client Connector utilizing the WebHttp binding. Neuron then routes the request through a Service Connector that calls a WCF service using the WebHttp binding. Both the client and service application utilize the JSON.Net library to serialize/deserialize the message bodies into the JSON format.
This sample utilizes JSON.Net to serialize and deserialize objects for transfer over HTTP. More information about JSON.Net can be found at http://james.newtonking.com/projects/json-net.aspx.
This sample uses the same Neuron solution as the other five REST samples. The solution contains five processes. This sample utilizes the “JSON Converter” process along with the service endpoint named “JSONServiceEndpoint”.
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 JSON Encoding sample.
Before running this sample, follow these instructions:
- Add the assembly Samples\Services\RESTServices\JSON\Newtonsoft.Json.dll to the Global Assembly Cache
- Add the assembly Samples\Services\RESTServices\JSON\Customer\bin\Debug\ Neuron.Samples.JSON.Customer.dll to the Global Assembly Cache.
- Open the sample solution JSON.sln in Visual Studio. Verify the Newtonsoft.Json assembly is correctly referenced in both the JSONClient and JSONService projects. If not, add a reference to the assembly added to the GAC in step 2.
- Build the solution.
- The Samples Launcher opens one Neuron Test Client. Select JSONLogSubscriber from the Party Id dropdown list and click the Connect button. Click on the Receive tab in the test client.
- In Visual Studio, press F5 to start both the JSONClient and JSONService projects in debug mode.
- In the JSONClient 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 performs a POST operation, a log message is also routed to the Test Client.
- When the client completes, press <ENTER> in both the client and service consoles to close the applications.