我是WSO2 DSS和REST架构的新手,我正在测试使用带有Microsoft SQL Server数据源的DSS创建的服务。我在下面创建了一个查询来获取员工信息
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个月。
非常感谢。
答案 0 :(得分:3)
作为补充信息,可以在DSS的定义中找到转义不可打印的字符。
对于手动编辑DSS的人,可以将属性escapeNonPrintableChar
添加到标记结果中
<result element="MyList" rowName="myRow" escapeNonPrintableChar="true">
答案 1 :(得分:2)
我得到了一个答案,数据库上有不可打印的字符,但它是数据的一部分,我不能尝试清理或删除它们,因为它们是数据的一部分。不允许在Web服务上检索它们,因为没有数据表示这就是我收到错误&#34;无效的凝视元素&#34;要解决此问题,我必须启用转义不可打印的字符,这是从WSO2 DSS 3.1.0开始引入的功能,并且可以使用WSO2 DSS UI打开。