0

我在尝试实现这个简单的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>

在我的用户表中,application_UID字段具有TEXT作为 SQL 类型。

问题是,当我尝试使用 DSS Try It 工具执行此查询调用服务时,对 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表列中?

4

1 回答 1

0

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

于 2018-02-19T08:21:14.530 回答