我是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个月。
非常感谢你。
最佳答案
作为附加信息,可以在DSS的定义中找到转义的不可打印字符。
对于手动编辑DSS的用户,您可以将属性escapeNonPrintableChar
添加到标签结果中,如下所示
<result element="MyList" rowName="myRow" escapeNonPrintableChar="true">