我已经创建了数据服务(DS),并将数据公开为REST资源。而且我可以通过下面给出的CURL命令成功检索数据。
curl -X GET -H "Accept: application/json" http://localhost:8280/services/TestDataService.HTTPEndpoint/Member/0
REST API资源模板为 Member / {MemberID} - DS Endpoint
答案是
{"Members":{"Email":"example@test.com","FirstName":"Mad","MembershipCategory":"Gold","InsuranceType":"Health","LastName":"Tim"}}
然后,我想使用WSO2 EI的 Data Mapper中介器将此JSON响应转换为CSV。 我知道还有其他方法可以通过其他中介程序或WSO2 API管理器来实现此用例。
我在WSO2 EI中创建了另一个具有模板的API资源
/ convertDetails / Member / {MemberID} - EI端点
无论如何,使用以下配置,当我从REST客户端调用REST API资源时,我无法获得正确的响应。
以下是我的调解流程,
<?xml version="1.0" encoding="UTF-8"?>
<api context="/convertDetails" name="MemberDetailsConversion" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/Member/{MemberID}">
<inSequence>
<log description="Request Log" level="full"/>
<send>
<endpoint>
<http method="get" uri-template="http://localhost:8280/services/TestDataService.HTTPEndpoint/Member/{uri.var.MemberID}"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<datamapper config="gov:datamapper/MemberDetailsMapping.dmc" inputSchema="gov:datamapper/MemberDetailsMapping_inputSchema.json" inputType="JSON" outputSchema="gov:datamapper/MemberDetailsMapping_outputSchema.json" outputType="CSV"/>
<log description="Response Log" level="full"/>
<respond/>
</outSequence>
<faultSequence/>
</resource>
</api>
但是当我调用EI REST资源端点http://localhost:8280/convertDetails/Member/0时,它仍然给我一个错误。我已经提取了下面堆栈的前几行。
[2018-11-01 10:30:30,817] [EI-Core] ERROR - DBInOutMessageReceiver Error in in-out message receiver
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Nested Exception:-
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'CallQuery.extractParams', cannot find parameter with type:query-param name:MemberID
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Source Data Service:-
Name: TestDataService
Location: /Users/mad/Documents/wso2ei-6.3.0/wso2/tmp/carbonapps/-1234/1541088489969TestDataServiceProjectCompositeApplication_1.0.0.car/TestDataService_1.0.0/TestDataService-1.0.0.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: _getmember_memberid
Current Params: {}
我假设我错过了配置中的某些内容。感谢您对此的帮助。