Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ export class Client extends EventEmitter {
}
}
}

if(options.overrideElementKey !== undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please document this in the README

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@w666 -- is it only the README change that is required that's holding up this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also needs a test. I added this one to my todo list.

this.wsdl.options.overrideElementKey = options.overrideElementKey;
}
if (options.overrideRootElement !== undefined) {
this.wsdl.options.overrideRootElement = options.overrideRootElement;
}
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export interface IWsdlBaseOptions {
valueKey?: string;
xmlKey?: string;
overrideRootElement?: { namespace: string; xmlnsAttributes?: IXmlAttribute[]; };
overrideElementKey?: Object
ignoredNamespaces?: boolean | string[] | { namespaces?: string[]; override?: boolean; };
ignoreBaseNameSpaces?: boolean;
/** escape special XML characters in SOAP message (e.g. &, >, < etc), default: true. */
Expand Down
14 changes: 14 additions & 0 deletions src/wsdl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,17 @@ export class WSDL {
public objectToXML(obj, name: string, nsPrefix: any, nsURI: string, isFirst?: boolean, xmlnsAttr?, schemaObject?, nsContext?: NamespaceContext) {
const schema = this.definitions.schemas[nsURI];

if(this.options.overrideElementKey && Object.keys(this.options.overrideElementKey).length > 0) {
for (let key in this.options.overrideElementKey) {
const overrideKey = this.options.overrideElementKey[key];
if (obj && obj[key]) {
Object.defineProperty(obj, overrideKey,
Object.getOwnPropertyDescriptor(obj, key));
delete obj[key];
}
}
}

let parentNsPrefix = nsPrefix ? nsPrefix.parent : undefined;
if (typeof parentNsPrefix !== 'undefined') {
// we got the parentNsPrefix for our array. setting the namespace-variable back to the current namespace string
Expand Down Expand Up @@ -1175,6 +1186,9 @@ export class WSDL {
this.options.forceSoap12Headers = options.forceSoap12Headers;
this.options.customDeserializer = options.customDeserializer;

if(options.overrideElementKey !== undefined) {
this.options.overrideElementKey = options.overrideElementKey;
}
if (options.overrideRootElement !== undefined) {
this.options.overrideRootElement = options.overrideRootElement;
}
Expand Down