uniformely process both json and xml request/response