Skip to content

Do not consider an HTTP error without content a SOAP fault - #1947

Open
sharanggupta wants to merge 1 commit into
spring-projects:mainfrom
sharanggupta:gh-1028-empty-500-response
Open

sharanggupta wants to merge 1 commit into
spring-projects:mainfrom
sharanggupta:gh-1028-empty-500-response

Conversation

@sharanggupta

Copy link
Copy Markdown

This fixes #1028, which still reproduces on main.

When a server answers with a 500 status code (or 400 for SOAP 1.2) and a SOAP content type, AbstractHttpSenderConnection.hasFault() returns true, so WebServiceTemplate.hasError() treats the response as a fault instead of an error. If the response has no content, receive() then returns null, the template logs "Received no response for request", and the call returns as if it had succeeded (null, or false for sendSourceAndReceiveToResult). The same error with another content type, or without a content type, already fails with a WebServiceTransportException.

hasFault() now also requires a response, since a fault is carried in the response. An empty 500 (or 400 for SOAP 1.2) is therefore handled as an error and raises a WebServiceTransportException with the status, for instance Server Error [500]. hasResponse() caches its result and keeps the byte it peeks when the content length is unknown, so calling it before receive() does not change what receive() reads.

Testing

Developed test first: the new tests failed against main and pass with the change.

  • AbstractHttpWebServiceMessageSenderIntegrationTests: an empty 500 with a text/xml content type is an error and not a fault, for the six HTTP message senders.
  • AbstractSoap11WebServiceTemplateIntegrationTests and AbstractSoap12WebServiceTemplateIntegrationTests: the WebServiceTemplate raises a WebServiceTransportException for an empty 500 (and an empty 400 for SOAP 1.2) with a SOAP content type, for the SAAJ and Axiom message factories.
  • ./gradlew :spring-ws-core:check :spring-ws-core:javadoc passes locally on JDK 25 (1044 tests in spring-ws-core, none skipped).

A response with a 500 status code, or a 400 status code for SOAP 1.2,
and a SOAP content type was considered a fault even when it had no
content. WebServiceTemplate then skipped its error handling, found no
response, and returned as if the call had succeeded.

AbstractHttpSenderConnection.hasFault() now also requires a response,
so such an error is reported as a WebServiceTransportException, like
an error with another content type already is.

See spring-projectsgh-1028

Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP 500 with no fault is not handled correctly [SWS-956]

2 participants