[
https://issues.apache.org/jira/browse/AXIS2-5929?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Robert Lazarski resolved AXIS2-5929.
------------------------------------
Resolution: Fixed
I applied the patch - just changed javax to jakarta - I didn't see the Github
PR until I applied the patch so I will close that.
> REST GET request using Accept HTTP Header to indicate JSON, does not working
> ----------------------------------------------------------------------------
>
> Key: AXIS2-5929
> URL: https://issues.apache.org/jira/browse/AXIS2-5929
> Project: Axis2
> Issue Type: Improvement
> Components: json, transports
> Affects Versions: 2.0.0
> Reporter: Marti Pamies Sola
> Priority: Minor
> Attachments: AbstractJSONOMBuilder.java,
> AbstractJSONOMBuilder.java.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:
> *
> {color:#505050}[http://localhost:8080/opencdefhirserver/services/FHIR/Binary/4295642378]{color}
> * {color:#505050}Accept =application/fhir+json
> {color}
> Where, FHIR is my service; Binary is the axis2 operation to be executed
> (mapping to a FHIR resource); and {color:#505050}4295642378{color} 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:
>
> {code:java}
> // 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");
> }
> {code}
> 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
> {code:java}
> if (contentType == null || "".equals(contentType)) {
> contentType = HTTPConstants.MEDIA_TYPE_X_WWW_FORM;
> } {code}
>
> 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í
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]