0

我是一名数据库开发人员,我们正在使用 WSO2 数据服务服务器来构建基于 Oracle 存储过程调用的 Web 服务。其中一个存储过程将数组作为输入参数。不幸的是,DSS 无法映射数组这个输入参数。尝试浏览 WSO2 文档,但没有。我尝试使用参数定义来制作标量或数组,如下所示。

有人可以帮忙解决需要进行哪些配置更改吗?

另外,您能否指出将数据数组作为输入参数的 RESTful 服务的 URL 是什么样的?

下面是示例 Oracle 存储过程代码和相应的 WSO2 DSS 配置脚本。数据库授权和许可不是问题。

/* PL/SQL Code Start */

create or replace type str_array as table of varchar2(100) ;

create or replace procedure procarray (
    pv_arr IN str_array,
    pv_rset OUT sys_refcursor)
AS
BEGIN
    open pv_rset for select column_value as str from table(pv_arr);
End;

show errors;  

/* PL/SQL Code End */

webservice配置如下

<data name="test_arrayCall">
   <config id="CDE_ODS_DIT">
      <property name="driverClassName">oracle.jdbc.driver.OracleDriver</property>
      <property name="url">jdbc:oracle:thin:@zzzz:1521</property>
      <property name="username">xxxxxxx</property> 
      <property name="password">yyyyyyy</property>
   </config>
   <query id="callarray" useConfig="CDE_ODS_DIT">
      <sql>call xxxxxxx.procarray(?,?);</sql>
      <result element="rows" rowName="row">
         <element column="STR" name="STR" namespace="STR" xsdType="string"/>
      </result>
      <param name="pv_arr" paramType="ARRAY" sqlType="STRING"/> <!-- When making a call the service response throws an Oracle Error -->

      <!-- Below parameter setting doesn't work and the service fails to get itself registered successfully --> 
      <!-- <param name="pv_arr" paramType="ARRAY" sqlType="ARRAY" structType="xxxxxxx.STR_ARRAY"/> /> -->

      <param name="pv_rset" sqlType="ORACLE_REF_CURSOR" type="OUT"/>
   </query>
   <operation name="getdata">
      <call-query href="callarray">
         <with-param name="pv_arr" query-param="pv_arr"/>
      </call-query>
   </operation>
</data>

以下是将两个值传递给存储过程 Request 时的示例请求和响应输出:

<body>
   <p:getdata xmlns:p="http://ws.wso2.org/dataservice">
      <!--1 or more occurrences-->
      <xs:pv_arr xmlns:xs="http://ws.wso2.org/dataservice">A</xs:pv_arr>
      <xs:pv_arr xmlns:xs="http://ws.wso2.org/dataservice">B</xs:pv_arr>
   </p:getdata>
</body>

回复 :

<soapenv:Fault xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:axis2ns14="http://ws.wso2.org/dataservice">
   <soapenv:Code>
      <soapenv:Value>axis2ns14:DATABASE_ERROR</soapenv:Value>
   </soapenv:Code>
   <soapenv:Reason>
      <soapenv:Text xml:lang="en-US">DS Code: DATABASE_ERROR
Nested Exception:-
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processStoredProcQuery'
DS Code: DATABASE_ERROR
Source Data Service:-
Name: test_arrayCall
Location: \test_arrayCall.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: getdata
Current Params: {pv_arr={A,B}}
Nested Exception:-
java.sql.SQLSyntaxErrorException: ORA-00911: invalid character


</soapenv:Text>
   </soapenv:Reason>
   <soapenv:Detail>
      <axis2ns13:DataServiceFault xmlns:axis2ns13="http://ws.wso2.org/dataservice">
         <axis2ns13:current_params>{pv_arr={A,B}}</axis2ns13:current_params>
         <axis2ns13:current_request_name>getdata</axis2ns13:current_request_name>
         <axis2ns13:nested_exception>java.sql.SQLSyntaxErrorException: ORA-00911: invalid character</axis2ns13:nested_exception>
         <axis2ns13:source_data_service>
            <axis2ns13:location>\test_arrayCall.dbs</axis2ns13:location>
            <axis2ns13:default_namespace>http://ws.wso2.org/dataservice</axis2ns13:default_namespace>
            <axis2ns13:description>N/A</axis2ns13:description>
            <axis2ns13:data_service_name>test_arrayCall</axis2ns13:data_service_name>
         </axis2ns13:source_data_service>
         <axis2ns13:ds_code>DATABASE_ERROR</axis2ns13:ds_code>
      </axis2ns13:DataServiceFault>
   </soapenv:Detail>
</soapenv:Fault>
4

1 回答 1

2

将 sql 查询编辑为

   <query id="callarray" useConfig="CDE_ODS_DIT">
      <sql>call xxxxxxx.procarray(?,str_array(?));</sql>
      <result element="rows" rowName="row">
         <element column="STR" name="STR" namespace="STR" xsdType="string"/>
      </result>
      <param name="pv_arr" paramType="ARRAY" sqlType="STRING"/> <!-- When making a call the service response throws an Oracle Error -->

      <!-- Below parameter setting doesn't work and the service fails to get itself registered successfully --> 
      <!-- <param name="pv_arr" paramType="ARRAY" sqlType="ARRAY" structType="xxxxxxx.STR_ARRAY"/> /> -->

      <param name="pv_rset" sqlType="ORACLE_REF_CURSOR" type="OUT"/>
   </query>

请注意,数组数据应在查询中作为类型 str_array 传递,如上述示例中所示

于 2014-10-03T10:06:16.787 回答