我尝试按照本教程创建一个带有JSON输出的DSS:https://docs.wso2.com/display/EI620/Using+JSON+with+Data+Services
它可以很好地处理一个简单的查询,我可以毫无问题地格式化输出。
现在,我尝试添加一个输入参数来按ID过滤记录,但它对我不起作用。我的REST,如教程中所述,是:GET http://{server_host}/services/Promemoria_PROMEMORIA_Tools/getCount/2
答案是:
Error processing GET request for : /services/Promemoria_PROMEMORIA_Tools/getCount/2</p><p>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:idp
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Source Data Service:-
Name: Promemoria_PROMEMORIA_Tools
Location: /Promemoria_PROMEMORIA_Tools.dbs
Description: Tool per permettere ad Amenta di inserire le pratiche fatte a mano.
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: _getgetcount_idp
Current Params: {}
字符串
我也试过:GET http://{server_host}/services/Promemoria_PROMEMORIA_Tools/getCount?idp=2但这是错误的,因为无法识别操作。
我在查询定义中把idp的属性defaultValue=“3”放在查询定义中,它就开始工作了..但是它忽略了REST中的值。
怎么了?这是我的安全局代码
<data name="Promemoria_PROMEMORIA_Tools" transports="http https local">
<description>Tool per permettere di inserire le pratiche fatte a mano.</description>
<config enableOData="false" id="OracleServizio_Promemoria2">
<property name="carbon_datasource_name">OracleServizio_Promemoria2</property>
</config>
<query id="getByCF" useConfig="OracleServizio_Promemoria2">
<sql>SELECT ID_ABILITAZIONE, ID_SERVIZIO, DESCR_SERVIZIO, CF_UTENTE, ID_CANALE_NOTIFICA, CANALE_NOTIFICA, ID_CONTATTO, CONTATTO, CANALE_ACQ, DATA_ACQ, CF_ACQ, PROTOCOLLO, DATA_PROT, PROV_UFF FROM SERVIZIO_PROMEMORIA.SE_MI_SCORDO_ABIL_SPORTELLO a where a.CF_UTENTE = :cf union all SELECT ID_ABILITAZIONE, ID_SERVIZIO, DESCR_SERVIZIO, CF_UTENTE, ID_CANALE_NOTIFICA, CANALE_NOTIFICA, ID_CONTATTO, CONTATTO, CANALE_ACQ, DATA_ACQ, CF_ACQ, PROTOCOLLO, DATA_PROT, PROV_UFF FROM SERVIZIO_PROMEMORIA.SE_MI_SCORDO_ABIL b where b.CF_UTENTE = :cf and b.CF_ACQ <> 'BATCH'</sql>
<result escapeNonPrintableChar="true" outputType="json">{
 "list": {
 "item": [{
 "id": "$ID_ABILITAZIONE",
 "service": {
 "id": "$ID_SERVIZIO",
 "info": "$DESCR_SERVIZIO"
 },
 "cfUser": "$CF_UTENTE",
 "channel": {
 "id": "$ID_CANALE_NOTIFICA",
 "info": "$CANALE_NOTIFICA"
 },
 "address": {
 "id": "$ID_CONTATTO",
 "info": "$CONTATTO"
 }
 }]
 }
}</result>
<param name="cf" sqlType="STRING"/>
</query>
<query id="getCount" useConfig="OracleServizio_Promemoria2">
<sql>SELECT ID_SERVIZIO, DESCR_SERVIZIO, ID_CANALE_NOTIFICA, CANALE_NOTIFICA, count(*) as recno FROM SERVIZIO_PROMEMORIA.SE_MI_SCORDO_ABIL_SPORTELLO a where a.ID_SERVIZIO=:idp group by ID_SERVIZIO, DESCR_SERVIZIO, ID_CANALE_NOTIFICA, CANALE_NOTIFICA</sql>
<param name="idp" paramType="SCALAR" sqlType="INTEGER"/>
<result escapeNonPrintableChar="true" outputType="json">{
 "list": {
 "item": [{
 "items": "$recno",
 "service": {
 "id": "$ID_SERVIZIO",
 "info": "$DESCR_SERVIZIO"
 },
 "channel": {
 "id": "$ID_CANALE_NOTIFICA",
 "info": "$CANALE_NOTIFICA"
 }
 }]
 }
}</result>
</query>
<resource method="GET" path="getByCF/{cf}">
<call-query href="getByCF">
<with-param name="cf" query-param="cf"/>
</call-query>
</resource>
<resource method="GET" path="getCount/{idp}">
<call-query href="getCount">
<with-param name="idp" query-param="idp"/>
</call-query>
</resource>
</data>
型
Roberto
2条答案
按热度按时间oug3syen1#
你能通过从DSS代码中的资源中删除/{idp}来尝试同样的方法吗?
字符串
jljoyd4f2#
我解决了这个问题,但我不太确定如何:)我试图从一开始就解释它。我通过WSO2控制台创建向导构建了一个SOAP服务。然后我用在线xml编辑器编辑了服务,并将其转换为REST。它在select中运行良好,输出正确,但我无法使用输入参数(如上所述)。
在我的测试中,我将“getCount”操作改为POST,但没有结果,但是当我将它重新设置为GET时,它神奇地开始工作了。
我认为WSO2存储了一个错误的配置,可能是向导做的。我完全删除了服务,并从一个空的.dbs文件重新启动,手动编写它。我用“上传”将其加载到WSO2中,它工作正常。我用在线xml编辑器编辑它,它仍然工作正常。
仅此而已