Webservices | Account Aggregation | XML Response | Error extracting response from XML

Hello,
I am looking for help to parse the XML response in Webservices connector. I am getting the below sample API xml response. It is a multiple users response, but I have given for one user in the example.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE USER_LIST_OUTPUT SYSTEM "https://testapi.rg3.apps.quad.com/user_list_output.dtd">
<USER_LIST_OUTPUT>
    <USER_LIST>
        <USER>
            <USER_LOGIN>usr3ch</USER_LOGIN>
            <USER_ID>76279</USER_ID>
            <CONTACT_INFO>
                <FIRSTNAME>
                    <![CDATA[Scan Service Account]]>
                </FIRSTNAME>
                <LASTNAME>
                    <![CDATA[CH Legacy User-AD Inactive]]>
                </LASTNAME>
                <EMAIL>
                    <![CDATA[[email protected]]]>
                </EMAIL>
                <ADDRESS1>
                    <![CDATA[123 Avenue of the Americas]]>
                </ADDRESS1>
                <CITY>
                    <![CDATA[New York]]>
                </CITY>
                <COUNTRY>USA</COUNTRY>
                <STATE>New York</STATE>
                <ZIP_CODE>
                    <![CDATA[10105]]>
                </ZIP_CODE>
            </CONTACT_INFO>
            <USER_STATUS>Active</USER_STATUS>
        </USER>
    </USER_LIST>
</USER_LIST_OUTPUT>

Below are the configuration in WS connector.
Headers
Content-Type: application/xml,text/xml
Response Information
Root Path: .//USER_LIST_OUTPUT/USER_LIST/USER/
Success Code: 2**
Response Mapping
Schema attributes (on the left column)
USER_LOGIN
USER_ID
Attribute Path (On the right column)

@USER_LOGIN
@USER_ID

Error

During Account Aggregation below error occurs
sailpoint.connector.ConnectorException: Error: Error extracting response from XML.

How should I configure the response to map the attributes like USER_LOGIN, USER_ID, FIRST_NAME in CONTACT_INFO?

Hi @suresh4iam,

for CONTACT_INFO try to put the path like this:
CONTACT_INFO/FIRSTNAME
CONTACT_INFO/LASTNAME
…

Thanks @enistri_devo.

The issue here is the response XML is not parsing correctly from the root path. The configured API (GET) is giving the above mentioned XML response when I executing it through Postman. But getting the XML parse error when I configure it in ISC.

After so much struggle I have resolved the issue by writing the WS AfterOperationRule. The rule is navigate through each node of the XML and assigned it to HashMap object and returned the same by assigning it to a data object as response.

In WS configuration, set the root path = ./data in Response and set Headers as below.
Content-Type = application/json
Accept = * / *

Update: Since many are requesting the code snippet of the rule, here I’m posting it.

Map userDetailsMap = new HashMap();
if (rawResponseObject != null) {
    //Create XPath
    XPath xpath = XPathFactory.newInstance().newXPath();
    XPathExpression xPathExpr = xpath.compile("/USER_LIST_OUTPUT/USER");
    NodeList nodes = (NodeList) xPathExpr.evaluate(doc, XPathConstants.NODESET);
    for (int i = 0; i < nodes.getLength(); i++) {
        Element node = (Element) nodes.item(i);
        // Get ASSIGNED_GROUPS
        ArrayList < String > assignedGrp = new ArrayList < String > ();
        NodeList assignedGrpNodeList = node.getElementsByTagName("ASSIGNED_GROUPS");
        if (assignedGrpNodeList != null && assignedGrpNodeList.getLength() > 0) {
            for (int i = 0; i < assignedGrpNodeList.getLength(); i++) {
                //get the groups element
                Element assetGrpElement = (Element) assignedGrpNodeList.item(i);
                NodeList GrpTitleNodeList = assetGrpElement.getElementsByTagName("GRP_TITLE");
                if (GrpTitleNodeList != null && GrpTitleNodeList.getLength() > 0) {
                    for (int j = 0; j < GrpTitleNodeList.getLength(); j++) {
                        //get the Group Title object in ASSIGNED_GROUPS
                        Element groupElement = (Element) GrpTitleNodeList.item(j);
                        String assetGrp = groupElement.getFirstChild().getNodeValue();
                        assignedGrp.add((assetGrp == null ? "" : assetGrp));
                    }
                    userDetailsMap.put("ASSIGNED_GROUPS", assignedGrp);
                }
            }
        }
        accountsToReturn.add(userDetailsMap);
    }
}
//Return the results in the data key
Map accountListMap = new HashMap();
accountListMap.put("data", accountsToReturn);
return accountListMap;
3 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.