savonrb / wasabi

A simple WSDL parser
MIT License
90 stars 84 forks source link

Nested complex #19

Closed kmcgrath closed 11 years ago

kmcgrath commented 11 years ago

I am using savon and wasabi to communicate with ServiceNow. Part of the WSDL structure looks like this:

<xsd:element name="getRecordsResponse">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element maxOccurs="unbounded" minOccurs="0" name="getRecordsResult">
        <xsd:complexType>
          <xsd:sequence>
           <xsd:element maxOccurs="1" minOccurs="0" name="active" type="xsd:boolean"/>
           <xsd:element maxOccurs="1" minOccurs="0" name="activity_due" type="xsd:string"/>
           <xsd:element maxOccurs="1" minOccurs="0" name="approval" type="xsd:string"/>
           <xsd:element maxOccurs="1" minOccurs="0" name="approval_set" type="xsd:string"/>
           <xsd:element maxOccurs="1" minOccurs="0" name="assigned_to" type="xsd:string"/>
           <xsd:element maxOccurs="1" minOccurs="0" name="assignment_group" type="xsd:string"/>
           ...

There is a complexType beneath an element, which wasabi does not process at the moment. And, of course, that info is critical to what I am trying to accomplish.

This code request has a fix (hack) that will read nested complexType elements. I don't know if this is "the answer", but thought I'd pass it up the line. Any suggestions or thoughts on handling this?

rubiii commented 11 years ago

hi kevin,

thanks for your contribution, but there's already a branch and a ticket to improve the parser. so i'd make sure your wsdl works with the new parser instead of adding yet another hack to the current implementation.

you can check it out and if you could donate your wsdl for testing, that would be great.

cheers, daniel

kmcgrath commented 11 years ago

I did checkout the sax-parser branch. I had to bump the version there to 3.0 (test with savon) and it had the same result as the master branch. I didn't spend much time there because I didn't know how far along that process was.

I can dig into that branch if that is right place to figure this out.

I'll see what I am allowed to send as far as the full WSDL goes. We have some custom fields that I might have to remove or modify, but I can send something for testing that mirrors this structure.

rubiii commented 11 years ago

the sax-parse branch is what's going to be used in savon 3.x. it still needs quite a lot of testing though, so the more people test it, the sooner this can be released. i didn't have the time to work on this recently, but it should work with the version3 branch of savon.

there are some pretty simple specs for the low-level "parser" and the more abstract "interpreter" which should get you started pretty easily.

if you really think you have to manually edit the wsdl, please make sure that it's still valid and can be parsed by soapUI. i can't base the implementation on invalid documents.

kmcgrath commented 11 years ago

This will work even better I think.

Found out ServiceNow has a demo site anyone can log into. The structure is exactly what I am dealing with. https://demo.service-now.com

I just tried with username/password: admin/admin

WSDL(s) can be found here: https://demo005.service-now.com/incident.do?WSDL https://demo005.service-now.com/incident.do?displayvalue=all&WSDL https://demo005.service-now.com/change_request.do?displayvalue=all&WSDL

The issue with the parser happens with getRecordsResult which is nested under getRecordsResponse. The definition is trying to describe that a getRecordsResponse can have an infinite number of getRecordsResult elements.

Thanks again. And anything I can do to help, just let me know.

rubiii commented 11 years ago

another service for integration testing. sweet :) if you think you can add specs for this demo site, please just go ahead and open another pull request. i'd appreciate your help.

rubiii commented 11 years ago

oh and if you can't do it, please just let me know as well.

kmcgrath commented 11 years ago

I should be able to add something. You want everything to be done based on the sax-parser branch, correct?

rubiii commented 11 years ago

right. let me know if you have any questions.