adobe / adobe/acc-js-sdk

XML representation not working

Open
#128 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
27
Forks
25
PR merge metrics
No merged PRs in 30d

Description

Hi,

There appears to be an issue when XML is set as representation and expected as output. This should probably be a PR instead of an issue, but here is explanation of the issue.

Minimal example:

```
const queryDef = {
schema: "nms:recipient",
operation: "select",
select: { node: [{ expr: "@id" }, { expr: "@email" }] },
lineCount: 50,
};

const query = client.NLWS.xml.xtkQueryDef.create(queryDef) // or xml set globally, same result
const result = await query.executeQuery()
```
Above throws error:
```
Error: TypeError: xmlRoot.hasAttribute is not a function
at Client._writeSoapCallParameters ([...]\@adobe\acc-js-sdk\src\client.js:1334:38)
```

Issue seems to be in @adobe\acc-js-sdk\src\client.js:1319 - function _writeSoapCallParameters:
```
var xmlValue = this._fromRepresentation(docName, paramValue, paramRepresentation || representation);
```
Issue is that at this point representation is SimpleJson. _fromRepresentation with 'xml' as representation always return paramValue without changes. If we instead convert to xml from SimpleJson the subsequent hasAttribute and rest of code works:

```
var xmlValue = this._convertToRepresentation(paramValue, "SimpleJson", paramRepresentation || representation);
```

Regards,
Jonas

Contributor guide

Open the contributing guide

Research direction

Read src/client.js around _writeSoapCallParameters at lines 1319-1334 and reproduce the minimal XML query example from the issue. Trace how the representation is selected before hasAttribute is called. Done means the XML-configured query executes without the TypeError and the existing representation behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.