I'm new to WSO2 DSS and REST Architecture and I'm testing a service that was created with DSS with a data source of Microsoft SQL Server. I created a query below which will get employee information
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 = ?
and assigned to a resource user/{login}. However I'm always getting an error
[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":""}}
The query was working fine and I've already created similar tests where the simple get would return results in JSON format. Upon checking the logs it has an error saying
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
Unfortunately I'm not able to understand the error and searching the net would produce different answers that I'm not really familiar with. I hope somebody can enlighten me on this as I'm only doing this for 2months.
Thank you very much.
I got an answer to this, there are non-printable characters on the database but it is part of data which I can't try to clean or delete them because they are part of data. Retrieving them on a web service will be not allowed because there is no representation of data that is why I'm getting the error "Invalid staring element" to resolve this I have to enable Escaping non printable characters which is a feature introduced from WSO2 DSS 3.1.0 onwards and can be turned on using the WSO2 DSS UI.