WebService connector Aggregation Issue (XML Response)

I am currently engaged in the development of a web service connector for an application that utilizes a SOAP API with XML responses.

For group aggregation, the data is typically formatted as follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<roleList>
    <roles>A</roles>
    <roles>B</roles>
    <roles>C</roles>
    <roles>D</roles>
</roleList>

I would like to inquire about the appropriate XPath to retrieve the aforementioned elements individually. While I am utilizing //roleList/roles in the attribute path, during the group aggregation process, the data is being returned as a single line with comma-separated values(A,B,C,D), rather than being retrieved one at a time, and another note if i am defining specific number in the array(//roleList/roles[1]) it is giving that group.

I have already tested this using the online Xpath tool, where I received the results in the expected format.

I would appreciate guidance on how to address this issue, or whether it is necessary to implement a solution by using webservice before or after operation rule.

hi @ramireddy

Your XPath //roleList/roles is correct, with a Web Services Connector encountering an issue where multiple XML elements (like <roles>) are returned as a single comma-separated string during group aggregation is expected for XML responses, however, What I would do is to use a Web Service After Operation Rule.

This rule allows you to split the string into individual values and return them as a proper list. Here’s a simple example:

String roles = (String) result.get("roles");
if (roles != null) {
    List<String> roleList = Arrays.asList(roles.split(","));
    result.put("roles", roleList);
}
1 Like

Thank you for your prompt response, Hyder. I am able to achieve this with the following configuration.

**Attribute Path**: text()
**Root Path:** //roleList/roles
1 Like