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

AssertionError: Invalid child type when WSDL contains imports or includes #322

Closed
wants to merge 2 commits into from
Closed

Conversation

boustanihani
Copy link

Any WSDL containing imports or includes will cause following error => "AssertionError: Invalid child type"
Sample WSDL to reproduce the issue => test/wsdl/strict/reproduce_issues_125_and_312.wsdl

Check: https://github.com/vpulim/node-soap/issues/125 (Almost a year ago)
Also Check : https://github.com/vpulim/node-soap/issues/312

I suggest those types of elements are ignored temporary until node-soap has some logic to handle them.

Fix "AssertionError: Invalid child type" caused by any WSDL containing imports or includes.
@jsdevel
Copy link
Collaborator

jsdevel commented Apr 12, 2014

@boustanihani looks good. The travis build failed though https://travis-ci.org/vpulim/node-soap/jobs/22829904#L366

@boustanihani
Copy link
Author

It says WSDL Parser (strict) should parse and describe reproduce_issues_125_and_312.wsdl:
Uncaught Error: Found unexpected element (wsdl:import) inside wsdl:definitions

@jsdevel
Copy link
Collaborator

jsdevel commented Apr 12, 2014

@boustanihani did you run npm test before pushing?

@boustanihani
Copy link
Author

no I did not :)

@boustanihani
Copy link
Author

I am new to using Git and this was my first Pull Request ever...

The main issue is that node-soap has no logic to handle includes & imports. So an "AssertionError: Invalid child type" is automatically thrown when such an element is found... I thought it is good to ignore those elements temporarily until node-soap has logic to handle them...

@jsdevel
Copy link
Collaborator

jsdevel commented Apr 12, 2014

@boustanihani glad I could be here for your first Pull Request!

What happens when you comment out your fix? Do you get a different error?

@boustanihani
Copy link
Author

Before the fix I was getting "AssertionError: Invalid child type" and after I put my fix there were no more errors... You know, WSDLs sometimes have "import" elements like in the sample I posted and node-soap has no logic to deal with such elements and for this reason node-soap regards such elements as invalid and thows the error above!

Check: http://www.w3.org/TR/wsdl#_document-n
2.1.1 Document Naming and Linking
WSDL allows associating a namespace with a document location using an import statement:

<definitions .... >
    <import namespace="uri" location="uri"/> *
</definitions>

@boustanihani
Copy link
Author

It is exactly this function which fails when child.name === "import" =>

AssertionError: Invalid child type
at DefinitionsElement.addChild (../node_modules/soap/lib/wsdl.js:383:5)

//...

DefinitionsElement.prototype.addChild = function(child) {
  var self = this;
  if (child instanceof TypesElement) {
    self.schemas = child.schemas;
  }
  else if (child instanceof MessageElement) {
    self.messages[child.$name] = child;
  }
  else if (child instanceof PortTypeElement) {
    self.portTypes[child.$name] = child;
  }
  else if (child instanceof BindingElement) {
    if (child.transport === 'http://schemas.xmlsoap.org/soap/http' ||
      child.transport === 'http://www.w3.org/2003/05/soap/bindings/HTTP/')
      self.bindings[child.$name] = child;
  }
  else if (child instanceof ServiceElement) {
    self.services[child.$name] = child;
  }
  else if (child instanceof DocumentationElement) {
  }
  else {
    assert(false, "Invalid child type");
  }
  this.children.pop();
};

//...

@nikmartin
Copy link

@jsdevel jsdevel mentioned this pull request Apr 17, 2014
j03w pushed a commit to j03w/node-soap that referenced this pull request May 5, 2014
@j03w
Copy link

j03w commented May 5, 2014

Umm, I think I may have fixed this see: commit. Although, I don't think it is quite right, semantic-wise but I don't really know much about XML orSOAP or WSDL so please let me know if you have any suggestion on how to improve it…

I also added a test case using http://api.temando.com/schema/2009_06/server.wsdl and it seems to work correctly, with import at the least.

OK, I made a new PR #337

j03w pushed a commit to j03w/node-soap that referenced this pull request May 6, 2014
j03w pushed a commit to j03w/node-soap that referenced this pull request May 7, 2014
@jsdevel jsdevel closed this in #337 May 7, 2014
christiaanwesterbeek pushed a commit to christiaanwesterbeek/node-soap that referenced this pull request Jun 30, 2014
diarmaidm pushed a commit to diarmaidm/node-soap that referenced this pull request Feb 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants