-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
please add a test |
// }); | ||
// }); | ||
|
||
it('check sort args on sequence required method', function(done) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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?
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. |
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. |
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. |
2 similar comments
need code review |
Looks good to me! |
@@ -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'); |
There was a problem hiding this comment.
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 + '...'
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
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.
@jsdevel
|
@@ -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)) { |
There was a problem hiding this comment.
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)) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks node-soap: https://github.com/vpulim/node-soap/pull/914/files#r118265159
I also got this vpulim#914 (comment) when running npm test and build failed. Now it passes.
I tried running test locally, but build failed for jshint. Did PR #931 to fix that first. |
I also got this vpulim#914 (comment) when running npm test and build failed. Now it passes.
I also got this #914 (comment) when running npm test and build failed. Now it passes.
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)
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)
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)
…new behaviour in vpulim#914)
…new behaviour in vpulim#914)
…new behaviour in vpulim#914)
I also got this vpulim#914 (comment) when running npm test and build failed. Now it passes.
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)
I also got this vpulim/node-soap#914 (comment) when running npm test and build failed. Now it passes.
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)
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.