javaspring-bootcisco-axl

Cisco AXL - Execute SQL Query, parse response


AXL 12.5, Apache CXF 3.3.6, OpenJDK 14, Spring Boot 2.3.0, executing a SQL query

String sqlStmt = "SELECT name FROM typeuserlocale";

ExecuteSQLQueryReq executeSQLQueryReq = new ExecuteSQLQueryReq();
executeSQLQueryReq.setSql(sqlStmt);

ExecuteSQLQueryRes executeSQLQueryRes = axlPort.executeSQLQuery(executeSQLQueryReq);

List<Object> rows = executeSQLQueryRes.getReturn().getRow();

gives a response of List<Object>, how to parse the result? To what to cast the Object?

Debugging shows that it is a ElementNSImpl. Trying to cast it to ElementNSImpl led to the IDE adding the dependency:

<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.9.1</version>
</dependency>

But casting it led to an exception:

java.lang.ClassCastException: 
class com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to class org.apache.xerces.dom.ElementNSImpl (com.sun.org.apache.xerces.internal.dom.ElementNSImpl is in module java.xml of loader 'bootstrap'; 
org.apache.xerces.dom.ElementNSImpl is in unnamed module of loader 'app')

Solution

  • Cast has to be done to org.w3c.dom.Element, and it works fine.