Can you define a JSON messaging structure or are you expecting some kind of arbitrary structure?
If you can define the structure of JSON messages, you can use WCF and its assembly in serializing / deserializing JSON messages for .NET types. Requests will be directly redirected to operations, and you will encode them like any other .NET method, without worrying about JSON or serialization =>
- Get parameters from an operation represented as .NET types / classes
- Process them
- Returns a .NET object as a result
WCF will handle everything related to routing request, deserialization and serialization operations.
If you cannot determine the structure of JSON messages, you cannot simply deserialize them into a .NET type. In this case, you can go with HttpHandler and somehow parse the JSON.
The difference is that WCF will do a lot of work for you, but you have to do it your own way. In HttpHandler you will have direct control over the request and response, but you will handle all the complexity yourself.
source share