Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
2.0.0
-
None
-
None
-
Patch
Description
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:
- http://localhost:8080/opencdefhirserver/services/FHIR/Binary/4295642378
- Accept =application/fhir+json
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.
Thanks,
Martí
Attachments
Attachments
Issue Links
- links to