Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-5929

REST GET request using Accept HTTP Header to indicate JSON, does not working



    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.8.3
    • None
    • json, transports
    • None
    • Patch


      I am implementing a REST services according to [HL7 FHIR|http://www.hl7.org/fhir/,] that must be able to return a Patient resource, both on xml or json, depending on http Accept header, and I am not able to implement it using axis.

      Request is:

      Where, FHIR is my service; Binary is the axis2 operation to be executed (mapping to a FHIR resource); and 4295642378 the resource id.

      The exception I get is:

      "No JSON message received through HTTP GET or POST"

      I've been reviewing source code and I guess the issue comes from this fragment of code at org.apache.axis2.json.AbstractJSONOMBuilder.java line 85:


      //            if ((index = requestURL.indexOf("=")) > 0) {
                      jsonString = requestURL.substring(index + 1);
                      reader = new StringReader(jsonString);
                  } else {
                      throw new AxisFault("No JSON message received through HTTP GET or POST");

      As it only accepts parameters as Query String, and when not provided it raise an exception.

      Also once previous code fixed, I realize that axis does not take care or Accept HTTP Header, so GET Requests where not payload is provided and so no contentType is specified, are just able to return as XML, but not JSON.

      See org.apache.axis2.transport.http.util.RESTUtil line 144

                  if (contentType == null || "".equals(contentType)) {
                      contentType = HTTPConstants.MEDIA_TYPE_X_WWW_FORM;


      I've implemented and improvement on both classes in order to be able to mange those request and done the Pull Request.

      Hope useful.





        1. AbstractJSONOMBuilder.java
          5 kB
          Marti Pamies Sola
        2. AbstractJSONOMBuilder.java.patch
          2 kB
          Marti Pamies Sola

        Issue Links



              Unassigned Unassigned
              martipamies Marti Pamies Sola
              0 Vote for this issue
              1 Start watching this issue