We are supporting data exchange in JSON, XML and SOAP for our customers. The bird view of the data flow would be like this
- Partner 1 sends request for some data with XML data
- Partner 2 sends request with JSON
- Partner 3 sends request with SOAP
To have a general approach for all partners. We have created a file for each partner where we are defining the partner's parameters and our corresponding parameters.
After getting the data required we process the data and generate a response. This response has to be sent to partners in their respective formats again. For that, we have templates where we just fill the response data into the template and sent that to the partner.
How do you normally solve this problem?
What am I working on? I am creating a generic parser which transforms partners request into our required format with the help of the file we have with parameters.
Content-Type
header in the request and parses the data using appropriate parser as registered on app startup. The business logic then works with simpleobject
classes with properties, so it doesn't care what format the request came in. Likewise, it can use theAccept
header to render the result in the expected format. So this way they can send SOAP and receive JSON in the same request.