Membrane API Gateway returns 500 Internal Server Error with the detail Error rewriting URI when the WSDL rewriter cannot rewrite the endpoint addresses and schema locations in a WSDL or XSD response.
The response contains the status 500 Internal Server Error, the detail Error rewriting URI, the problem type https://membrane-api.io/problems/internal and a link to this page. The URI field shows the requested path. The type internal means that the gateway could not complete the processing of the message. In production mode, the title is replaced by Internal Server Error and the details are left out.
When a client downloads a WSDL through the gateway, the addresses in it must point to the gateway instead of the backend. The rewriter changes the endpoint location and the schemaLocation values accordingly. It runs in the response flow for GET requests whose response is labeled as XML. It runs as the wsdlRewriter plugin, and internally in wsdlPublisher and soapProxy.
The response is labeled as XML, for example with text/xml, but its body is not well-formed XML. A typical case is an HTML error page from the backend that carries an XML content type.
The WSDL or XSD contains a DOCTYPE. Membrane's hardened XML parser rejects DTDs.
Inside wsdlPublisher or soapProxy: the configured WSDL, or a schema it references, cannot be resolved. The error document for the missing file is then passed to the rewriter, which fails on it. The underlying problem is the missing file, see Could not resolve file.
With wsdlRewriter and its path setting: rewriting a location or schemaLocation value fails because the value or path is not a valid URL.
The response body cannot be read or decoded, for example because the Content-Encoding is wrong.
The same link also appears when the wsdlRewriter plugin throws an exception that it does not turn into an error response itself. Membrane then aborts the exchange with 500 Internal Server Error, and the detail reads Aborting! Exception caused in wsdl-rewriting during … flow. with the request URI and the flow. Membrane logs every occurrence with the full stack trace. Unless the exception points to your configuration or to the message content, this usually indicates a bug in Membrane.
DOCTYPE, and use an XML content type only for XML bodies.wsdlPublisher and soapProxy: check that the wsdl and all referenced schemaLocation paths exist. Relative paths are resolved against the directory of the configuration file.wsdlRewriter: check that path and the addresses in the WSDL are valid URLs.error level. If the causes above do not explain it, report the problem with the stack trace on GitHub Issues.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: trueconfiguration: production: true
Add the configuration document to your apis.yaml and separate it from the APIs with ---. The title then reads Internal Server Error, and the details and the link to this page are left out. If the response contains a log key, search the gateway log for it to find the full error message.
If the plugin is nested inside a request, response or abort element and fails with an unexpected exception there, the exception message, the stack trace and the link to this page are currently sent even in production mode. Fix the failing plugin rather than relying on production mode to hide them.
Configuration reference:
Tutorials with runnable examples:
Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.