This is an automated email from the ASF dual-hosted git repository. robertlazarski pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
commit b324ff181814c3c9371f4bc6df89db46fc19c46e Author: Robert Lazarski <[email protected]> AuthorDate: Sat Nov 21 06:38:31 2026 -1000 Document that enableJSONOnly covers GET, PUT and DELETE The Spring Boot JSON guides, the starter guide and the REST guide now say that a JSON-only deployment refuses any request whose media type is not application/json, whatever the HTTP method, and that a plain query-string GET gets a 400. The distribution axis2.xml files keep enableJSONOnly=false, so the REST guide's examples still work there. Co-Authored-By: Claude Fable 5.2 <[email protected]> --- src/site/xdoc/docs/json-springboot-tomcat11-userguide.xml | 11 +++++++++++ src/site/xdoc/docs/json-springboot-userguide.xml | 11 +++++++++++ src/site/xdoc/docs/rest-ws.xml | 7 +++++++ src/site/xdoc/docs/spring-boot-starter.xml | 7 +++++++ 4 files changed, 36 insertions(+) diff --git a/src/site/xdoc/docs/json-springboot-tomcat11-userguide.xml b/src/site/xdoc/docs/json-springboot-tomcat11-userguide.xml index 12921b5713..7606ce7ebc 100644 --- a/src/site/xdoc/docs/json-springboot-tomcat11-userguide.xml +++ b/src/site/xdoc/docs/json-springboot-tomcat11-userguide.xml @@ -289,6 +289,17 @@ disables Axis2 functionality not required for JSON and sets up the server to exp <li><strong>Request Filtering:</strong> Blocks non-JSON requests at the transport level, providing an additional security barrier</li> </ul> +<p><strong>All HTTP methods are covered.</strong> Since 2.0.3 the check applies to GET, PUT and +DELETE as well as POST. A request is accepted only when the media type of its +<code>Content-Type</code> header is exactly <code>application/json</code>; parameters such as +<code>; charset=UTF-8</code> are allowed, but <code>application/json</code> appearing only inside +a parameter is not. A plain browser or <code>curl</code> GET to a service URL such as +<code>/services/MyService/myOperation?arg=value</code> is therefore refused with HTTP 400 and +the JSON-only error body. Call services with POST and a JSON body, or add +<code>-H "Content-Type: application/json"</code> to the request. Metadata requests +(<code>?wsdl</code>, <code>?xsd</code>, the service listing) and the OpenAPI and Swagger UI +endpoints are not affected.</p> + <p><strong>Security Best Practice:</strong> When combined with HTTPS-only enforcement (required for HTTP/2), enableJSONOnly creates a secure, hardened API endpoint that accepts only authenticated JSON requests over encrypted connections.</p> </p> diff --git a/src/site/xdoc/docs/json-springboot-userguide.xml b/src/site/xdoc/docs/json-springboot-userguide.xml index 64dd3a9048..7cb7750c80 100644 --- a/src/site/xdoc/docs/json-springboot-userguide.xml +++ b/src/site/xdoc/docs/json-springboot-userguide.xml @@ -192,6 +192,17 @@ disables Axis2 functionality not required for JSON and sets up the server to exp <li><strong>Request Filtering:</strong> Blocks non-JSON requests at the transport level, providing an additional security barrier</li> </ul> +<p><strong>All HTTP methods are covered.</strong> Since 2.0.3 the check applies to GET, PUT and +DELETE as well as POST. A request is accepted only when the media type of its +<code>Content-Type</code> header is exactly <code>application/json</code>; parameters such as +<code>; charset=UTF-8</code> are allowed, but <code>application/json</code> appearing only inside +a parameter is not. A plain browser or <code>curl</code> GET to a service URL such as +<code>/services/MyService/myOperation?arg=value</code> is therefore refused with HTTP 400 and +the JSON-only error body. Call services with POST and a JSON body, or add +<code>-H "Content-Type: application/json"</code> to the request. Metadata requests +(<code>?wsdl</code>, <code>?xsd</code>, the service listing) and the OpenAPI and Swagger UI +endpoints are not affected.</p> + <p><strong>Security Best Practice:</strong> When combined with HTTPS-only enforcement (required for HTTP/2), enableJSONOnly creates a secure, hardened API endpoint that accepts only authenticated JSON requests over encrypted connections.</p> </p> diff --git a/src/site/xdoc/docs/rest-ws.xml b/src/site/xdoc/docs/rest-ws.xml index 02bd92281b..b3c4207e96 100644 --- a/src/site/xdoc/docs/rest-ws.xml +++ b/src/site/xdoc/docs/rest-ws.xml @@ -140,6 +140,13 @@ via HTTP GET. For example, the following URL requests the Version Service via HTTP GET. However, the Web service arriving via GET assumes REST. Other parameters are converted into XML and put into the SOAP body.</p> <pre>http://127.0.0.1:8080/axis2/services/Version/getVersion</pre> +<p><strong>Note:</strong> this does not work on a JSON-only deployment. When +<code>enableJSONOnly</code> is <code>true</code> in axis2.xml, as it is in the Spring Boot +starter's default JSON mode, GET, PUT and DELETE requests are refused with HTTP 400 unless +they carry <code>Content-Type: application/json</code> (since 2.0.3). The axis2.xml in the +WAR and binary distributions sets it to <code>false</code>, so the examples on this page +work there unchanged. See the +<a href="json-springboot-userguide.html">JSON and REST with Spring Boot User's Guide</a>.</p> <p>The result can be shown in the browser as follows:</p> <img src="images/userguide/http-get-ws.jpg"/> diff --git a/src/site/xdoc/docs/spring-boot-starter.xml b/src/site/xdoc/docs/spring-boot-starter.xml index 36258e5c23..29236930a8 100644 --- a/src/site/xdoc/docs/spring-boot-starter.xml +++ b/src/site/xdoc/docs/spring-boot-starter.xml @@ -352,6 +352,13 @@ axis2.mode=json <p>Uses <code>JsonRpcMessageReceiver</code>, <code>JSONBasedDefaultDispatcher</code>, and <code>enableJSONOnly=true</code>. Choose this for new services, MCP/AI integration, and REST/OpenAPI consumers.</p> +<p>With <code>enableJSONOnly=true</code>, every request to a service must carry +<code>Content-Type: application/json</code>, whatever the HTTP method. Since 2.0.3 this +includes GET, PUT and DELETE: a plain GET that passes its arguments in the query string +is refused with HTTP 400. Send POST with a JSON body, or set the JSON content type on +the request. If a deployment needs query-string GET access to its services, use a +custom axis2.xml (see below) with <code>enableJSONOnly=false</code>, +which gives up the JSON-only enforcement for all methods.</p> <h3>SOAP mode (<code>axis2.mode=soap</code>)</h3> <pre>
