cxf icon indicating copy to clipboard operation
cxf copied to clipboard

Attributes support in serialize/deserialize functions [wsdl2js]

Open R-ens opened this issue 9 years ago • 4 comments

Added attributes support in serialize and deserialize functions:

Serialize:

function OBJECT_serialize(cxfjsutils, elementName, extraNamespaces) {
    /* some code .... */
    if (this._value !== null) {
        xml = xml + 'value="' + this._value + '" ';
    }
    // It support also default values:
    if (this._timeout !== null) {
        xml = xml + 'timeout="' + this._timeout + '" ';
    } else {
        xml = xml + 'timeout="0" ';
    }
}

Deserialize:

function OBJECT_deserialize(cxfjsutils, element) {
    /* some code .... */
    var attributes = element.attributes;
    for (var i = 0; i < attributes.length; i++) {
        if (attributes[i].nodeName === 'timeout') {
            newobject.setTimeout(attributes[i].nodeValue)
        }
        /* etc. */
    }
}

Better array support:

this._item = []; // array

// Old situation (it's always override the previous value)
function OBJECT_setItem(value) { this._item = value; }

// New situation (add separate items or arrays)
function OBJECT_addItem(Item) {
    (Item instanceof Array ? this._item = this._item.concat(Item) : this._item.push(Item));
}

R-ens avatar Apr 10 '17 09:04 R-ens

Don't worry about the build timing out. Any chance of modifying/adding some tests for these new features?

coheigea avatar Apr 12 '17 10:04 coheigea

@coheigea As you can see I have modified the unit tests in my last commit, so they runs well again.

R-ens avatar Apr 14 '17 20:04 R-ens

The unit tests have been modified, but I'd prefer to see a unit test added that (for example) failed with the old code but passes with the new code. Does changing from "add" to "set" for arrays break the API by the way?

coheigea avatar Apr 18 '17 08:04 coheigea

Definitely concerned about the set->add change. That will certainly break peoples code. Can the original method be retained with the add method being added?

dkulp avatar May 03 '17 17:05 dkulp