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

Remove brackets from argsScheme string if they exist #929

Closed
wants to merge 3 commits into from

Conversation

alanmarcell
Copy link

We have an argsScheme issue due its string contains brackets. Removing it does not affect existing tests ans solves the problem

We have an argsScheme issue due its strign contains brackets. Remeving it does not affect existing tests ans solves the problem
_ = require('lodash'),
sinon = require('sinon'),
wsdl = require('../lib/wsdl');
soap = require('..'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

please remove any changes that aren't related to your fix.

Reverting unrelated changes made by beautify
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 93.145% when pulling bffd10b on amodev:master into 14c8a3f on vpulim:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 93.145% when pulling bffd10b on amodev:master into 14c8a3f on vpulim:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 93.145% when pulling bffd10b on amodev:master into 14c8a3f on vpulim:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 93.145% when pulling bffd10b on amodev:master into 14c8a3f on vpulim:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 93.145% when pulling 945d634 on amodev:master into 14c8a3f on vpulim:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 93.145% when pulling 945d634 on amodev:master into 14c8a3f on vpulim:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 93.145% when pulling 945d634 on amodev:master into 14c8a3f on vpulim:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 93.145% when pulling 945d634 on amodev:master into 14c8a3f on vpulim:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 93.145% when pulling 13e30c7 on amodev:master into 14c8a3f on vpulim:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 93.145% when pulling 13e30c7 on amodev:master into 14c8a3f on vpulim:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 93.145% when pulling 13e30c7 on amodev:master into 14c8a3f on vpulim:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 93.145% when pulling 13e30c7 on amodev:master into 14c8a3f on vpulim:master.

assert.ok(JSON.stringify(sequencedMethodRequest) === JSON.stringify(sequencedRequest));
done();
});
it('check sort args on sequence required method', function (done) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

it('should ...

});
describe('Method args sequence', function () {

it('check if method required sequence args', function (done) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

it('should ...

Copy link
Author

Choose a reason for hiding this comment

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

These test was already there
My test start with should, by the way

@@ -212,6 +212,7 @@ Client.prototype._setSequenceArgs = function(argsScheme, args) {
return args;
}
for (var partIndex in argsScheme) {
partIndex = partIndex.replace('[]','')
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like a pretty big breaking change to me. Just because there aren't tests, doesn't mean it's good for use. What are we trying to solve here?

Copy link
Author

Choose a reason for hiding this comment

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

Well, I agree it's a very specific issue, then i forked and create my own npm package to solve urgent my issue, but I decided to pull request it anyway.
I think it's a error with the SOAP server, but I have an argScheme with brackets while it should be just a string. If I try to pass the arg with the bracket the application crashes

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's such a specific scenario I guess we should guard it behind some option? I know it won't be an elegant solution, but it would fit both needs if the option will trigger the newly introduced behaviour and proceed "as is" if not provided...?

Copy link
Collaborator

Choose a reason for hiding this comment

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

we could end up breaking things for devs that depend on the brackets being there, so I think an option would be good.

Copy link
Author

Choose a reason for hiding this comment

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

I tried to use with the brackets, but I had an error with parse response:

Error: Error: Cannot parse response
  at kplClient.CadastrarCliente (src/connectors/applications/kpl/services/kplService.js:35:25)
  at node_modules/soap/lib/client.js:180:7
  at finish (node_modules/soap/lib/client.js:451:14)
  at parseSync (node_modules/soap/lib/client.js:436:12)
  at node_modules/soap/lib/client.js:412:14
  at Request._callback (node_modules/soap/lib/http.js:118:5)
  at Request.self.callback (node_modules/request/request.js:188:22)
  at Request.<anonymous> (node_modules/request/request.js:1171:10)
  at IncomingMessage.<anonymous> (node_modules/request/request.js:1091:12)
  at endReadableNT (_stream_readable.js:975:12)
  at _combinedTickCallback (internal/process/next_tick.js:80:11)
  at process._tickCallback (internal/process/next_tick.js:104:9)

Copy link
Collaborator

Choose a reason for hiding this comment

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

sounds like you have a bug in your code

Copy link
Author

Choose a reason for hiding this comment

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

It happens when I try to use the string with the brackets. I don't know if the field can have brackets at all, but in my case it cannot.
If i use the field without brackets, the field does not come to my args, due its difference to the field from the Scheme, with the brackets.

Copy link
Contributor

Choose a reason for hiding this comment

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

@alanmarcell is it possible for you to share the source code of your kplService.js? The client.parseSync() is "just" a proxy to wsdl.xmlToObject() with a try/catch block around it. So, if anything, the xmlToObject() method would fail.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, of course

'use strict';

let
  soap = require('soap');

class KplService {

  createConnection(url) {
    return new Promise((resolve, reject) => {
      soap.createClient(url, (err, client) => {
        if (err) {
          return reject(new Error(err));
        }
        return resolve(client);
      });
    });
  }

  createClient(kplClient, args) {
    return new Promise((resolve, reject) => {
      kplClient.CadastrarCliente(args, (err, response) => {
        if (err) {
          return reject(new Error(err));
        }
        if (response.CadastrarClienteResult.ResultadoOperacao.Codigo !== 200002) {
          return reject(new Error(response.CadastrarClienteResult.ResultadoOperacao.ExceptionMessage));
        }
        return resolve(response.CadastrarClienteResult.Rows);
      });
    });
  }

  createOrder(kplClient, args) {
    return new Promise((resolve, reject) => {
      kplClient.InserirPedido(args, (err, response) => {
        if (err) {
          return reject(new Error(err));
        }
        if (response.InserirPedidoResult.ResultadoOperacao.Codigo !== 200001) {
          return reject(new Error(response.InserirPedidoResult.ResultadoOperacao.ExceptionMessage));
        }
        return resolve(response.InserirPedidoResult.Rows);
      });
    });
  }
}

Copy link
Author

Choose a reason for hiding this comment

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

I call the service this way:

[...]
        const kplClient = await KplService.createConnection(url)

        args.ListaDeClientes = {
          'DadosClientes': DadosClientes
        }

        // I tried this way:
        // args.ListaDeClientes = {  
        //   'DadosClientes[]': DadosClientes
        // }

        // And this way:
        // args.ListaDeClientes = [{
        //   'DadosClientes': DadosClientes
        // }]
        // With no success

        let res = await KplService.createClient(kplClient, args)
[...]

@herom
Copy link
Contributor

herom commented May 29, 2017

This is probably (or better to say, I'm sure it is) describing what the failing test added with #933 describes.

@herom
Copy link
Contributor

herom commented May 29, 2017

@alanmarcell would you mind checkin' out the broken branch of my forked repo at https://github.com/herom/node-soap/tree/broken and try your luck with the latest fix? I really do think that this relates to your issue and is probably a fix which allows us to fix the regression and keep the newly introduced possibility of having a "sequenced" output 👍

@jsdevel
Copy link
Collaborator

jsdevel commented May 30, 2017

Reverting #914 with #937

@herom
Copy link
Contributor

herom commented May 31, 2017

@alanmarcell would you mind trying the new 0.19.1 build and see if this fixes your bug?

@sm-hejazi
Copy link

sm-hejazi commented Jun 7, 2017

Hi everyone
I'm sorry I mention it here, I could not find the issue place!!! :-)
I have an issue:
console.log(client.describe().soap_ansarMobApp.soapPort.login)
.
.
Output:
login: { "input": { "context": { "data[]": { "key": "xs:string", "value": "xs:string", "targetNSAlias": "tns", "targetNamespace": "http://sample.com/" }, "targetNSAlias": "tns", "targetNamespace": "http://sample.com/" }, "request": { "password": "xs:string", "username": "xs:string", "targetNSAlias": "tns", "targetNamespace": "http://sample.com/" }, "targetNSAlias": "tns", "targetNamespace": "http://sample.com/" }, "output": { "return": "xs:string", "targetNSAlias": "tns", "targetNamespace": "http://sample.com/" } }

I want to know what object should I use to send?

client.login(loginObj, function (err, result) {})

I use : loginObj: { "context": [], "request": { "username": "_username", "password": "_password" }
but get ValidatorWSException.

Thank you
Always happy and victorious.

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.

5 participants