Open Source API Gateway

400 Bad Request: SOAP to REST Transformation Failed

Membrane API Gateway returns an error with the detail Could not transform using XSLT! when the soap2Rest plugin cannot apply its XSLT stylesheet, either to turn the incoming SOAP request into a REST request, or to turn the REST response into a SOAP response.

The Error Response

The response contains the title User error., the detail Could not transform using XSLT!, the exception, the problem type https://membrane-api.io/problems/user and a link to this page. Only the status tells the two directions apart:

Request Transformation Failed

The status is 400 Bad Request. The request did not reach the backend.

Response Transformation Failed

The error happens in the response flow, so the client receives 500 Internal Server Error. In production mode, the title is replaced by Internal Server Error.

What the soap2Rest Plugin Does

The soap2Rest plugin lets SOAP clients call a REST backend. It turns the exchange into an XML document and applies requestXSLT to create the REST request. The REST response is turned into an XML document, too, and responseXSLT creates the SOAP response from it.

api:
port: 2000
flow:
- soap2Rest:
requestXSLT: request.xslt
responseXSLT: response.xslt
target:
url: https://api.predic8.de
api:
  port: 2000
  flow:
    - soap2Rest:
        requestXSLT: request.xslt
        responseXSLT: response.xslt
  target:
    url: https://api.predic8.de

Common Causes

The SOAP Request Is Not Well-Formed

In the request flow, the body of the SOAP request is not well-formed XML.

The Backend Response Is Not Well-Formed

In the response flow, the backend response is declared as XML or JSON in its Content-Type but is not well-formed, so it cannot be turned into the XML document that the stylesheet reads.

The Stylesheet Cannot Be Loaded

The stylesheet in requestXSLT or responseXSLT cannot be found or does not compile. Stylesheets are loaded on first use, so this shows up when the first request arrives, not at startup.

The Stylesheet Fails

The stylesheet fails at runtime, for example through an xsl:message terminate="yes" or an error in an XPath expression.

How to Fix It

  1. Check the log. Membrane logs the full exception at error level. The status tells you whether the request (400) or the response (500) failed.
  2. As a client, send a well-formed SOAP message.
  3. As an operator, check the requestXSLT and responseXSLT locations, and test the stylesheets against sample messages.
  4. If the backend returns malformed bodies, fix the backend or the Content-Type it sends.

Hide Details in Production

By default, Membrane runs in development mode and adds details to error responses that help you find the problem. These details may reveal information about your setup. In production, turn them off:

configuration:
production: true
configuration:
  production: true

Add the configuration document to your apis.yaml and separate it from the APIs with ---.

Related Documentation

Configuration reference:

← All Membrane error messages

Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.