2

我是 WSO2 DSS 和 REST 架构的新手,我正在测试一个使用 DSS 创建的服务,其数据源是 Microsoft SQL Server。我在下面创建了一个查询,它将获取员工信息

SELECT e.employee_id[Employee_Id],
  e.employee_code[Employee_Code],
  e.name_eng[Employee_Name_Eng],
  e.name_arb[Employee_Name_Arb],
  o.description_arb[Organization_Unit_Arb],
  o.description_eng[Organization_Unit_Eng],
  g.description_arb[Grade_Arb],
  g.description_eng[Grade_Eng],
  d.description_arb[Designation_Arb],
  d.description_eng[Designation_Eng],
  e.email[Email],
  r.role_name[Role]
FROM employee_master e
LEFT OUTER JOIN organizations o
ON o.organization_id = e.organization_id
LEFT OUTER JOIN grades g
ON g.grade_id = e.grade_id
LEFT OUTER JOIN designations d
ON d.designation_id = e.designation_id
LEFT OUTER JOIN sec_users u
ON e.employee_id = u.employee_id
LEFT OUTER JOIN sec_user_roles ur
ON ur.user_id = u.user_id,
LEFT OUTER JOIN sec_roles r
ON ur.role_id   = r.role_id
WHERE r.role_id =
  (SELECT MAX(role_id) FROM sec_user_roles WHERE user_id = u.user_id)
AND u.login    =  ?

并分配给资源用户/{login}。但是我总是遇到错误

[ec2-user@ip-172-31-37-209 ~]$ curl -i -H "Accept: application/json" -X GET http://54.76.120.61:9764/services/FTE/user/103
HTTP/1.1 500 Internal Server Error
Transfer-Encoding: chunked
Date: Tue, 19 Aug 2014 07:42:31 GMT
Connection: close
Server: WSO2 Carbon Server

{"Fault":{"faultcode":"soapenv:Server","faultstring":"Error while writing to the output stream using JsonWriter","detail":""}}

查询运行良好,我已经创建了类似的测试,其中简单的 get 将以 JSON 格式返回结果。在检查日志时,它有一个错误说

Caused by: DS Fault Message: Error in 'SQLQuery.processNormalQuery'
DS Code: DATABASE_ERROR
Source Data Service:-
Name: FTE
Location: /FTE.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: _getuser_login
Current Params: {login=103}
Nested Exception:-
DS Fault Message: Error in XML generation at StaticOutputElement.execute
DS Code: UNKNOWN_ERROR
Nested Exception:-
javax.xml.stream.XMLStreamException: Invalid Staring element


        at org.wso2.carbon.dataservices.core.description.query.SQLQuery.processNormalQuery(SQLQuery.java:864)
        at org.wso2.carbon.dataservices.core.description.query.SQLQuery.runQuery(SQLQuery.java:2290)
        at org.wso2.carbon.dataservices.core.description.query.Query.execute(Query.java:282)
        at org.wso2.carbon.dataservices.core.engine.CallQuery.executeElement(CallQuery.java:179)
        at org.wso2.carbon.dataservices.core.engine.CallQueryGroup.executeElement(CallQueryGroup.java:111)
        at org.wso2.carbon.dataservices.core.engine.OutputElement.execute(OutputElement.java:89)
        at org.wso2.carbon.dataservices.core.description.resource.Resource.execute(Resource.java:67)
        at org.wso2.carbon.dataservices.core.engine.DataService.invoke(DataService.java:462)
        at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:96)
        ... 46 more
Caused by: DS Fault Message: Error in XML generation at StaticOutputElement.execute
DS Code: UNKNOWN_ERROR
Nested Exception:-
javax.xml.stream.XMLStreamException: Invalid Staring element

        at org.wso2.carbon.dataservices.core.engine.StaticOutputElement.executeElement(StaticOutputElement.java:258)
        at org.wso2.carbon.dataservices.core.engine.OutputElement.execute(OutputElement.java:89)
        at org.wso2.carbon.dataservices.core.engine.OutputElementGroup.executeElement(OutputElementGroup.java:106)
        at org.wso2.carbon.dataservices.core.engine.OutputElement.execute(OutputElement.java:89)
        at org.wso2.carbon.dataservices.core.description.query.Query.writeResultEntry(Query.java:396)
        at org.wso2.carbon.dataservices.core.description.query.SQLQuery.processNormalQuery(SQLQuery.java:857)
        ... 54 more
Caused by: javax.xml.stream.XMLStreamException: Invalid Staring element
        at org.apache.axis2.json.gson.GsonXMLStreamWriter.writeStartElement(GsonXMLStreamWriter.java:239)
        at org.wso2.carbon.dataservices.core.engine.XMLWriterHelper.writeResultElement(XMLWriterHelper.java:144)
        at org.wso2.carbon.dataservices.core.engine.StaticOutputElement.executeElement(StaticOutputElement.java:250)
        ... 59 more

不幸的是,我无法理解该错误,并且在网上搜索会产生我不太熟悉的不同答案。我希望有人能启发我,因为我只做了 2 个月。

非常感谢你。

4

2 回答 2

3

作为附加信息,转义不可打印字符可以在 DSS 的定义中找到。

对于手动编辑 DSS 的人,您可以escapeNonPrintableChar像这样将属性添加到标签结果中

<result element="MyList" rowName="myRow" escapeNonPrintableChar="true">
于 2015-08-10T14:51:41.133 回答
2

我得到了答案,数据库中有不可打印的字符,但它是数据的一部分,我无法尝试清理或删除它们,因为它们是数据的一部分。不允许在 Web 服务上检索它们,因为没有数据表示,这就是为什么我收到错误“无效的凝视元素”来解决这个问题我必须启用转义不可打印字符,这是 WSO2 DSS 引入的一个功能从 3.1.0 开始,可以使用 WSO2 DSS UI 打开。

于 2014-08-20T08:15:00.873 回答