WSO2 Integration多资源API POST正常GET返回202未调用端点问题
使用场景
在WSO2 Integration Studio中开发集成服务时,创建了1个包含2个资源的API,分别为POST方法的/createIssues资源、GET方法的/getIssues资源。
问题现象
运行集成服务测试时,POST请求可正常执行并调用对应端点,但GET请求直接返回202 Accepted状态码,未触发后端端点调用;查看日志发现GET资源inSequence中的log日志可正常打印,但<call>中介器未执行对应端点的调用逻辑。
相关配置代码
<api context="/flow" name="companyflow" xmlns="http://ws.apache.org/ns/synapse"> <resource methods="POST" uri-template="/createIssues"> <inSequence> <call> <endpoint key="IssueEndpoint"/> </call> <respond/> </inSequence> <outSequence/> <faultSequence/> </resource> <resource methods="GET" uri-mapping="/getIssues"> <inSequence> <log> <property name="text" value="HelloThere"/> </log> <call> <endpoint key="issuesList"/> </call> <respond/> </inSequence> <outSequence/> <faultSequence/> </resource> </api>
根因分析
问题核心原因是单个API下混用了uri-template和uri-mapping两种资源路径定义属性,不符合WSO2 Synapse引擎的路由规则:
同一API下的所有资源必须统一使用同一种路径定义方式,混用会导致路由分发器匹配逻辑错乱,部分资源的中介链执行中断,直接返回默认的202 Accepted响应,不会执行后续的端点调用逻辑。
初步排查的属性差异方向是正确的,POST资源正常是因为引擎优先匹配了使用uri-template定义的资源,使用uri-mapping的GET资源匹配后出现了执行链断裂问题。
修复方案
- 将GET资源的
uri-mapping="/getIssues"属性修改为uri-template="/getIssues",保证API下所有资源统一使用uri-template定义路径,修正后的GET资源配置如下:
<resource methods="GET" uri-template="/getIssues"> <inSequence> <log> <property name="text" value="HelloThere"/> </log> <call> <endpoint key="issuesList"/> </call> <respond/> </inSequence> <outSequence/> <faultSequence/> </resource>
- 保存修改后重新部署集成服务,再次发起GET请求即可正常触发
<call>中介器调用后端端点,不会再出现直接返回202的问题。
内容的提问来源于stack exchange,提问作者Hyperion
相关产品推荐
相关产品推荐

