同样的方法也适用于 Micro Integrator。我可以通过将以下配置添加到
deployment.toml
文件来使其工作。我尝试使用 Mocky 端点,它返回带有 text/html
ContentType 标头的 JSON 负载。
[[custom_message_formatters]]
class = "org.apache.synapse.commons.json.JsonStreamFormatter"
content_type = "text/html"
[[custom_message_builders]]
class = "org.apache.synapse.commons.json.JsonStreamBuilder"
content_type = "text/html"
API
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse" name="MockyAPI" context="/mocky">
<resource methods="GET" uri-template="/getResponse">
<inSequence>
<log level="full">
<property name="message" value="Calling Mocky endpoint"/>
</log>
<send>
<endpoint>
<http method="GET" uri-template="https://run.mocky.io/v3/073c9d3d-4ab0-448e-af60-20f8880253c8"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full">
<property name="message" value="Received response from Mocky endpoint"/>
</log>
<send/>
</outSequence>
<faultSequence>
<log level="full">
<property name="message" value="Error occurred while calling Mocky endpoint"/>
</log>
<send/>
</faultSequence>
</resource>
</api>