You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WSO2 Integration Studio部署API后无法获取text/html响应的问题

问题描述

我使用WSO2 Integration Studio实现了一个API,但未收到正确的响应。预期返回text/html类型的响应,实际收到的却是其他类型,请问该如何解决?

使用Postman调用原生API的截图
使用Postman调用Integration Studio中API的截图

以下是我的Integration Studio中API的配置代码:

<?xml version="1.0" encoding="UTF-8"?>
<api context="/****" name="***" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="POST" uri-template="/****">
        <inSequence>
            <property description="messageProperty" name="messageType" scope="axis2" type="STRING" value="text/xml"/>
            <call>
                <endpoint>
                    <http method="post" uri-template="https://www.amenbank.com.tn/php/simulator.php?ts=1684227888868">
                        <suspendOnFailure>
                            <initialDuration>-1</initialDuration>
                            <progressionFactor>-1</progressionFactor>
                            <maximumDuration>0</maximumDuration>
                        </suspendOnFailure>
                        <markForSuspension>
                            <retriesBeforeSuspension>0</retriesBeforeSuspension>
                        </markForSuspension>
                    </http>
                </endpoint>
            </call>
            <respond/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>
解决方案

问题根源在于你配置的messageType属性强制将响应类型设为text/xml,覆盖了后端原生API返回的text/html类型。按以下方式修改即可:

  • 方案一:保留后端原始响应类型
    直接删除<property description="messageProperty" name="messageType" scope="axis2" type="STRING" value="text/xml"/>这一行,让API原样返回后端的响应类型。

  • 方案二:强制返回text/html类型
    把messageType的属性值改为text/html,确保响应类型固定为预期格式:

    <property description="messageProperty" name="messageType" scope="axis2" type="STRING" value="text/html"/>
    

修改完成后重新部署API,用Postman测试就能得到预期的text/html响应。

内容的提问来源于stack exchange,提问作者manar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 16:40:25