为什么我尝试执行WSO2 DSS插入查询时获得“不支持的数据类型:TEXT作为输入参数”?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了为什么我尝试执行WSO2 DSS插入查询时获得“不支持的数据类型:TEXT作为输入参数”?相关的知识,希望对你有一定的参考价值。

我发现一些困难尝试实现这个简单的WSO2 DSS服务,该服务在mysql数据库上执行插入查询。

我已经实现了这项服务:

<data name="user-dss" transports="http https local">
    <config id="user_db">
        <property name="driverClassName">com.mysql.jdbc.Driver</property>
        <property name="url">jdbc:mysql://127.0.0.1:3306/digital_services_DB</property>
        <property name="username">MY_USERNAME</property>
        <property name="password">MY_PSWD</property>
    </config>
    <query id="insert_user" returnGeneratedKeys="true" useConfig="user_db">
        <sql>
            insert into User(
                application_UID,
                country_id,
                localization_id,
                local_user_id,
                isActive,
                isFullProfile
                )
            values(
                :application_UID,
                :country_id,
                :localization_id,
                :local_user_id,
                :is_active,
                :is_full_profile
            )
        </sql>
        <result element="GeneratedKeys" rowName="Entry" useColumnNumbers="true">
            <element column="1" name="ID" xsdType="integer"/>
        </result>
        <param name="application_UID" sqlType="TEXT"/>
        <param name="country_id" sqlType="BIGINT"/>
        <param name="localization_id" sqlType="BIGINT"/>
        <param name="local_user_id" sqlType="BIGINT"/>
        <param name="is_active" sqlType="BIT"/>
        <param name="is_full_profile" sqlType="BIT"/>
    </query>

    <operation name="AddUser">
        <call-query href="insert_user">
            <with-param name="application_UID" query-param="application_uid"/>
            <with-param name="country_id" query-param="country_id"/>
            <with-param name="localization_id" query-param="localization_id"/>
            <with-param name="local_user_id" query-param="local_user_id"/>
            <with-param name="is_active" query-param="is_active"/>
            <with-param name="is_full_profile" query-param="is_full_profile"/>
        </call-query>
    </operation>
</data>

在我的User表中,application_UID字段将TEXT作为SQL类型。

问题是当我尝试使用DSS试用工具执行此查询调用服务时,在Try It工具中执行以下调用:

<body>
   <p:AddUser xmlns:p="http://ws.wso2.org/dataservice">
      <!--Exactly 1 occurrence-->
      <p:application_UID>ABC123</p:application_UID>
      <!--Exactly 1 occurrence-->
      <p:country_id>2</p:country_id>
      <!--Exactly 1 occurrence-->
      <p:localization_id>2</p:localization_id>
      <!--Exactly 1 occurrence-->
      <p:local_user_id>2000</p:local_user_id>
      <!--Exactly 1 occurrence-->
      <p:is_active>1</p:is_active>
      <!--Exactly 1 occurrence-->
      <p:is_full_profile>1</p:is_full_profile>
   </p:AddUser>
</body>

我在WSO2日志中获得以下错误,并且未执行查询:

TID: [-1234] [] [2018-01-18 12:41:48,376] ERROR {org.wso2.carbon.dataservices.core.DBInOutMessageReceiver} -  Error in in-out message receiver {org.wso2.carbon.dataservices.core.DBInOutMessageReceiver}
DS Code: DATABASE_ERROR
Nested Exception:-
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processPreNormalQuery': DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.
DS Code: UNKNOWN_ERROR

DS Code: DATABASE_ERROR
Source Data Service:-
Name: user-dss
Location: /opt/wso2/wso2ei/wso2/tmp/carbonapps/-1234/1516275560106userreg-cap_1.0.0.car/user-dss_1.0.0/user-dss-1.0.0.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: AddUser
Current Params: {local_user_id=2000, is_active=1, is_full_profile=1, application_UID=ABC123, country_id=2, localization_id=2}
Nested Exception:-
DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.
DS Code: UNKNOWN_ERROR



        at org.wso2.carbon.dataservices.core.dispatch.SingleDataServiceRequest.processRequest(SingleDataServiceRequest.java:75)
        at org.wso2.carbon.dataservices.core.dispatch.DataServiceRequest.dispatch(DataServiceRequest.java:357)
        at org.wso2.carbon.dataservices.core.DataServiceProcessor.dispatch(DataServiceProcessor.java:41)
        at org.wso2.carbon.dataservices.core.DBInOutMessageReceiver.invokeBusinessLogic(DBInOutMessageReceiver.java:57)
        at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:42)
        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
        at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:404)
        at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:151)
        at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processPreNormalQuery': DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.
DS Code: UNKNOWN_ERROR

DS Code: DATABASE_ERROR
Source Data Service:-
Name: user-dss
Location: /opt/wso2/wso2ei/wso2/tmp/carbonapps/-1234/1516275560106userreg-cap_1.0.0.car/user-dss_1.0.0/user-dss-1.0.0.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: AddUser
Current Params: {local_user_id=2000, is_active=1, is_full_profile=1, application_UID=ABC123, country_id=2, localization_id=2}
Nested Exception:-
DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.
DS Code: UNKNOWN_ERROR


        at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:102)
        at org.wso2.carbon.dataservices.core.dispatch.SingleDataServiceRequest.processRequest(SingleDataServiceRequest.java:73)
        ... 12 more
TID: [-1234] [] [2018-01-18 12:41:48,384] ERROR {org.apache.synapse.transport.passthru.ServerWorker} -  Error processing POST request for : /services/user-dss.SOAP12Endpoint/AddUser {org.apache.synapse.transport.passthru.ServerWorker}
org.apache.axis2.AxisFault: DS Code: DATABASE_ERROR
Nested Exception:-
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processPreNormalQuery': DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.
DS Code: UNKNOWN_ERROR

DS Code: DATABASE_ERROR
Source Data Service:-
Name: user-dss
Location: /opt/wso2/wso2ei/wso2/tmp/carbonapps/-1234/1516275560106userreg-cap_1.0.0.car/user-dss_1.0.0/user-dss-1.0.0.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: AddUser
Current Params: {local_user_id=2000, is_active=1, is_full_profile=1, application_UID=ABC123, country_id=2, localization_id=2}
Nested Exception:-
DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.
DS Code: UNKNOWN_ERROR



        at org.wso2.carbon.dataservices.core.DBUtils.createAxisFault(DBUtils.java:740)
        at org.wso2.carbon.dataservices.core.DBInOutMessageReceiver.invokeBusinessLogic(DBInOutMessageReceiver.java:67)
        at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:42)
        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
        at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:404)
        at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:151)
        at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processPreNormalQuery': DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.
DS Code: UNKNOWN_ERROR

DS Code: DATABASE_ERROR
Source Data Service:-
Name: user-dss
Location: /opt/wso2/wso2ei/wso2/tmp/carbonapps/-1234/1516275560106userreg-cap_1.0.0.car/user-dss_1.0.0/user-dss-1.0.0.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: AddUser
Current Params: {local_user_id=2000, is_active=1, is_full_profile=1, application_UID=ABC123, country_id=2, localization_id=2}
Nested Exception:-
DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.
DS Code: UNKNOWN_ERROR


        at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:102)
        at org.wso2.carbon.dataservices.core.dispatch.SingleDataServiceRequest.processRequest(SingleDataServiceRequest.java:73)
        at org.wso2.carbon.dataservices.core.dispatch.DataServiceRequest.dispatch(DataServiceRequest.java:357)
        at org.wso2.carbon.dataservices.core.DataServiceProcessor.dispatch(DataServiceProcessor.java:41)
        at org.wso2.carbon.dataservices.core.DBInOutMessageReceiver.invokeBusinessLogic(DBInOutMessageReceiver.java:57)
        ... 9 more
TID: [-1234] [] [2018-01-18 12:41:48,376] ERROR {org.wso2.carbon.dataservices.core.DBInOutMessageReceiver} -  Error in in-out message receiver {org.wso2.carbon.dataservices.core.DBInOutMessageReceiver}
DS Code: DATABASE_ERROR
Nested Exception:-
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processPreNormalQuery': DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.
DS Code: UNKNOWN_ERROR

DS Code: DATABASE_ERROR
Source Data Service:-
Name: user-dss
Location: /opt/wso2/wso2ei/wso2/tmp/carbonapps/-1234/1516275560106userreg-cap_1.0.0.car/user-dss_1.0.0/user-dss-1.0.0.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: AddUser
Current Params: {local_user_id=2000, is_active=1, is_full_profile=1, application_UID=ABC123, country_id=2, localization_id=2}
Nested Exception:-
DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.
DS Code: UNKNOWN_ERROR



        at org.wso2.carbon.dataservices.core.dispatch.SingleDataServiceRequest.processRequest(SingleDataServiceRequest.java:75)
        at org.wso2.carbon.dataservices.core.dispatch.DataServiceRequest.dispatch(DataServiceRequest.java:357)
        at org.wso2.carbon.dataservices.core.DataServiceProcessor.dispatch(DataServiceProcessor.java:41)
        at org.wso2.carbon.dataservices.core.DBInOutMessageReceiver.invokeBusinessLogic(DBInOutMessageReceiver.java:57)
        at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:42)
        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
        at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:404)
        at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:151)
        at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processPreNormalQuery': DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.
DS Code: UNKNOWN_ERROR

DS Code: DATABASE_ERROR
Source Data Service:-
Name: user-dss
Location: /opt/wso2/wso2ei/wso2/tmp/carbonapps/-1234/1516275560106userreg-cap_1.0.0.car/user-dss_1.0.0/user-dss-1.0.0.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: AddUser
Current Params: {local_user_id=2000, is_active=1, is_full_profile=1, application_UID=ABC123, country_id=2, localization_id=2}
Nested Exception:-
DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.
DS Code: UNKNOWN_ERROR


        at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:102)
        at org.wso2.carbon.dataservices.core.dispatch.SingleDataServiceRequest.processRequest(SingleDataServiceRequest.java:73)
        ... 12 more
TID: [-1234] [] [2018-01-18 12:41:48,384] ERROR {org.apache.synapse.transport.passthru.ServerWorker} -  Error processing POST request for : /services/user-dss.SOAP12Endpoint/AddUser {org.apache.synapse.transport.passthru.ServerWorker}
org.apache.axis2.AxisFault: DS Code: DATABASE_ERROR
Nested Exception:-
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processPreNormalQuery': DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.
DS Code: UNKNOWN_ERROR

DS Code: DATABASE_ERROR
Source Data Service:-
Name: user-dss
Location: /opt/wso2/wso2ei/wso2/tmp/carbonapps/-1234/1516275560106userreg-cap

所以问题似乎与此错误消息有关:

DS Fault Message: [user-dss]  Found Unsupported data type : TEXT as input parameter.

似乎TEXT不是有效类型。但是怎么可能呢? TEXT是一种有效的SQL类型。

如何解决此问题并将TEXT值插入application_UID表列?

答案

在Dataservice代码中,在验证输入参数时,我们检查sqlType是否属于某些数据类型,如果不是,则抛出给定的异常。您可以从here找到相关的代码库。这里评估了大多数数据类型,但也可能存在一些丢失的数据类型。但是,为了避免这个问题,您可以使用sqlType作为字符串,因为它最后将输出参数注册为java.sql.Types.VARCHAR,并且SQL Types中也没有文本特定类型

以上是关于为什么我尝试执行WSO2 DSS插入查询时获得“不支持的数据类型:TEXT作为输入参数”?的主要内容,如果未能解决你的问题,请参考以下文章

WSO2 企业集成商 DSS

此执行计划是否满足要求?

WSO2 IS - 尝试启动服务器时“系统无法找到指定的路径”

使用 WSO2 在 BigQuery 中插入多条记录

WSO2 BAM 的创建小工具

DSS 无法连接到不同的 Oracle 数据库版本