Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fields sequence if it's required (need help) #914

Merged
merged 8 commits into from
Jan 25, 2017

Conversation

vfrbgt
Copy link
Contributor

@vfrbgt vfrbgt commented Jan 16, 2017

I want sort args on call soap method if sequence required(check parent element sequence). It's my implement for this functional. But I have problem 3 test not passed. Please help me fix it. I really need this functionality in your library. Thank you.

@coveralls
Copy link

coveralls commented Jan 16, 2017

Coverage Status

Coverage decreased (-0.2%) to 92.996% when pulling 847ec16 on vfrbgt:master into 54d20e8 on vpulim:master.

@jsdevel
Copy link
Collaborator

jsdevel commented Jan 16, 2017

please add a test

@coveralls
Copy link

coveralls commented Jan 17, 2017

Coverage Status

Coverage decreased (-0.6%) to 92.611% when pulling f382547 on vfrbgt:master into 54d20e8 on vpulim:master.

// });
// });

it('check sort args on sequence required method', function(done) {
Copy link
Contributor

Choose a reason for hiding this comment

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

how does this test guarantee the functionality of sorting the args in the correct "sequence" order?

if(argsScheme) {
args = this._setSequenceArgs(argsScheme, args);
}
console.log(args);
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove calls to console alltogether - use debug instead

Client.prototype._isSequenceRequired = function(method) {
try {
var tns = this.wsdl.definitions.xmlns.tns;
var childrenName = this.wsdl.definitions.schemas[tns].complexTypes.pullFileParams.children[0].name;
Copy link
Contributor

Choose a reason for hiding this comment

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

are these pullFileParams specific to your project or are they defined in the specification?

if(typeof argsScheme[partIndex] !== 'object') {
result[partIndex] = args[partIndex];
}
else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, pull else { to the same line as the closing curly-brace of the if {}

-->

if {
//code
} else {
// code
}


Client.prototype._getArgsScheme = function(methodName) {
try {
return this.wsdl.definitions.messages[methodName].parts;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please consider that we're using lodash within our project which does provide a get() method which can achieve the same thing you're doing here, without using a costly try/catch

@@ -202,6 +242,17 @@ Client.prototype._invoke = function(method, args, location, callback, options, e
},
xmlnsSoap = "xmlns:" + envelopeKey + "=\"http://schemas.xmlsoap.org/soap/envelope/\"";

if(name === 'pullFile') {
Copy link
Contributor

Choose a reason for hiding this comment

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

again, is pullFile a specified element of the WSDL specification or "just" related to your project?

@vfrbgt
Copy link
Contributor Author

vfrbgt commented Jan 18, 2017

sorry after use test xml files from this projects i detected errors in my implementstion, in this time i'm try fix it. I'm write here when i finish fix this functional. Thanks for review.

@vfrbgt
Copy link
Contributor Author

vfrbgt commented Jan 18, 2017

Can you help me understand, how i can get info about methods and his arguments. I tried get it from client.wsdl.definitions but unable understand which property i must use for this, some properties duplicate data about method arguments (for example client.wsdl.definitions.schemas[tns].complexTypes[methodName+'Params'].children[0].children and this.wsdl.definitions.bindings.RpcExample.methods.pullFile.input.parts.params.children[0].children) How i can get this data correctly.

@vfrbgt
Copy link
Contributor Author

vfrbgt commented Jan 18, 2017

I want understand why for https://swsim.stamps.com/swsim/swsimv50.asmx?wsdl and test file rpcexample.wsdl for exmaple client.describe().SwsimV50.SwsimV50Soap.CreateIndicium.input and client.describe().RpcExample.RpcExample.pullFile.input.params have different structure.

@coveralls
Copy link

coveralls commented Jan 20, 2017

Coverage Status

Coverage decreased (-0.3%) to 92.85% when pulling 4cecdec on vfrbgt:master into 54d20e8 on vpulim:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 92.85% when pulling 4cecdec on vfrbgt:master into 54d20e8 on vpulim:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 92.85% when pulling 4cecdec on vfrbgt:master into 54d20e8 on vpulim:master.

@coveralls
Copy link

coveralls commented Jan 20, 2017

Coverage Status

Coverage decreased (-0.3%) to 92.85% when pulling f94684c on vfrbgt:master into 54d20e8 on vpulim:master.

@vfrbgt
Copy link
Contributor Author

vfrbgt commented Jan 20, 2017

need code review

@jsdevel
Copy link
Collaborator

jsdevel commented Jan 20, 2017

Looks good to me!

@coveralls
Copy link

coveralls commented Jan 24, 2017

Coverage Status

Coverage decreased (-0.1%) to 93.021% when pulling 73dcc1d on vfrbgt:master into 54d20e8 on vpulim:master.

@coveralls
Copy link

coveralls commented Jan 25, 2017

Coverage Status

Coverage decreased (-0.1%) to 93.038% when pulling 923cfb6 on vfrbgt:master into 54d20e8 on vpulim:master.

@@ -182,6 +182,54 @@ Client.prototype._defineMethod = function(method, location) {
};
};

Client.prototype._isSequenceRequired = function(methodName) {
var tns = this.wsdl.definitions.$targetNamespace;
var methodRequestName = _.result(this.wsdl.definitions, 'messages.'+methodName+'.$name');
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add spaces between operators? e.g. 'messages.' + methodName + '...'

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice if we had this failing the build as part of linting too (for another PR if needed).

return false;
}
var complexTypeName = _.result(this.wsdl.definitions, 'messages.'+methodRequestName+'.element.$name');
var modeOfComplexType = _.result(this.wsdl.definitions, 'schemas[\''+tns+'\'].elements.'+complexTypeName+'.children[0].children[0].name');
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you break this up so the line is shorter? same comment with spaces around operators

}
}


Copy link
Collaborator

Choose a reason for hiding this comment

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

at most there should be one empty line.

@coveralls
Copy link

coveralls commented Jan 25, 2017

Coverage Status

Coverage decreased (-0.1%) to 93.038% when pulling b59b1e7 on vfrbgt:master into 54d20e8 on vpulim:master.

@jsdevel jsdevel merged commit 5dbcb1d into vpulim:master Jan 25, 2017
@aleung
Copy link
Contributor

aleung commented Feb 24, 2017

@jsdevel test/sequence-test.js has lint error when I execute npm run test. Why your CI passed?

> jshint index.js lib test

test/sequence-test.js: line 53, col 5, Expected '}' to have an indentation at 7 instead at 5.
test/sequence-test.js: line 55, col 1, Expected '}' to have an indentation at 3 instead at 1.

2 errors

@@ -202,6 +258,13 @@ Client.prototype._invoke = function(method, args, location, callback, options, e
},
xmlnsSoap = "xmlns:" + envelopeKey + "=\"http://schemas.xmlsoap.org/soap/envelope/\"";

if(this._isSequenceRequired(name)) {
Copy link
Contributor

@pihvi pihvi May 24, 2017

Choose a reason for hiding this comment

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

I had to revert to v.0.18.0 as this breaks node-soap. When a client is formed from a WSDL and it has an array inside nested object in input like this (the way client.describe() tells):

input: {
   ResourceId: "s:string",
   PeriodList: {
       PeriodType[]: {
            PeriodId: "s:int",
            Status: "s:string",
            DateFrom: "s:dateTime",
            DateTo: "s:dateTime"...

It will ignore given array in input PeriodType: [...], but will accept "PeriodType[]": {} and it will generate malformed XML by generating <PeriodType[]></PeriodType[]> element.

v.0.18.0 Works as expected by accepting PeriodType: [...], also works when this if is disabled if(false && this._isSequenceRequired(name)) {

Copy link
Contributor

@pihvi pihvi left a comment

Choose a reason for hiding this comment

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

@herom
Copy link
Contributor

herom commented May 27, 2017

@pihvi would it be possible for you to add a failing test for this? I think we should follow the path of fixing a bug by first creating (and merging!) a failing test for it. What do you think @jsdevel ?

pihvi added a commit to pihvi/node-soap that referenced this pull request May 28, 2017
I also got this vpulim#914 (comment)
when running npm test and build failed. Now it passes.
@pihvi
Copy link
Contributor

pihvi commented May 28, 2017

I tried running test locally, but build failed for jshint. Did PR #931 to fix that first.

pihvi added a commit to pihvi/node-soap that referenced this pull request May 29, 2017
I also got this vpulim#914 (comment)
when running npm test and build failed. Now it passes.
herom pushed a commit that referenced this pull request May 29, 2017
I also got this #914 (comment)
when running npm test and build failed. Now it passes.
pihvi added a commit to pihvi/node-soap that referenced this pull request May 29, 2017
v. 0.19.0 broke giving array as a parameter. It would now accept the "array"
with invalid syntax like this: {input: {PeriodList: {"PeriodType[]": {PeriodId: '1'}}}}
i.e. it wants the "[]" as the parameter name and it does not accept an array, but an
object. The invalid syntax then prints invalid XML like this:
"<PeriodList><PeriodType[]><PeriodId>1</PeriodId></PeriodType[]></PeriodList>"

This test shows old and correct syntax.

This test passes if you revert commit 5dbcb1d
or disable if statement mentioned in
vpulim#914 (review)
pihvi added a commit to pihvi/node-soap that referenced this pull request May 29, 2017
v. 0.19.0 broke giving array as a parameter. It would now accept the "array"
with invalid syntax like this: {input: {PeriodList: {"PeriodType[]": {PeriodId: '1'}}}}
i.e. it wants the "[]" as the parameter name and it does not accept an array, but an
object. The invalid syntax then prints invalid XML like this:
"<PeriodList><PeriodType[]><PeriodId>1</PeriodId></PeriodType[]></PeriodList>"

This test shows old and correct syntax.

This test passes if you revert commit 5dbcb1d
or disable if statement mentioned in
vpulim#914 (review)
@pihvi
Copy link
Contributor

pihvi commented May 29, 2017

@herom added a failing test for this in PR #933

herom pushed a commit that referenced this pull request May 29, 2017
v. 0.19.0 broke giving array as a parameter. It would now accept the "array"
with invalid syntax like this: {input: {PeriodList: {"PeriodType[]": {PeriodId: '1'}}}}
i.e. it wants the "[]" as the parameter name and it does not accept an array, but an
object. The invalid syntax then prints invalid XML like this:
"<PeriodList><PeriodType[]><PeriodId>1</PeriodId></PeriodType[]></PeriodList>"

This test shows old and correct syntax.

This test passes if you revert commit 5dbcb1d
or disable if statement mentioned in
#914 (review)
herom added a commit to herom/node-soap that referenced this pull request May 29, 2017
herom added a commit to herom/node-soap that referenced this pull request May 29, 2017
herom added a commit to herom/node-soap that referenced this pull request May 29, 2017
jsdevel added a commit that referenced this pull request May 30, 2017
jsdevel added a commit that referenced this pull request May 30, 2017
@jsdevel jsdevel mentioned this pull request May 30, 2017
jsdevel added a commit that referenced this pull request May 30, 2017
jcald1 pushed a commit to jcald1/node-soap that referenced this pull request Jun 8, 2017
I also got this vpulim#914 (comment)
when running npm test and build failed. Now it passes.
jcald1 pushed a commit to jcald1/node-soap that referenced this pull request Jun 8, 2017
v. 0.19.0 broke giving array as a parameter. It would now accept the "array"
with invalid syntax like this: {input: {PeriodList: {"PeriodType[]": {PeriodId: '1'}}}}
i.e. it wants the "[]" as the parameter name and it does not accept an array, but an
object. The invalid syntax then prints invalid XML like this:
"<PeriodList><PeriodType[]><PeriodId>1</PeriodId></PeriodType[]></PeriodList>"

This test shows old and correct syntax.

This test passes if you revert commit 5dbcb1d
or disable if statement mentioned in
vpulim#914 (review)
jcald1 pushed a commit to jcald1/node-soap that referenced this pull request Jun 8, 2017
johnolson2219 pushed a commit to johnolson2219/soap-nodeJS that referenced this pull request Aug 26, 2023
I also got this vpulim/node-soap#914 (comment)
when running npm test and build failed. Now it passes.
johnolson2219 pushed a commit to johnolson2219/soap-nodeJS that referenced this pull request Aug 26, 2023
v. 0.19.0 broke giving array as a parameter. It would now accept the "array"
with invalid syntax like this: {input: {PeriodList: {"PeriodType[]": {PeriodId: '1'}}}}
i.e. it wants the "[]" as the parameter name and it does not accept an array, but an
object. The invalid syntax then prints invalid XML like this:
"<PeriodList><PeriodType[]><PeriodId>1</PeriodId></PeriodType[]></PeriodList>"

This test shows old and correct syntax.

This test passes if you revert commit 5dbcb1d715843310c799419f260e0962722cd2fb
or disable if statement mentioned in
vpulim/node-soap#914 (review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants