Skip to content

Commit

Permalink
recursive element should work in wsdl
Browse files Browse the repository at this point in the history
  • Loading branch information
dimichgh committed May 21, 2015
1 parent 5177f66 commit 2b75e79
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/wsdl.js
Expand Up @@ -869,11 +869,21 @@ ElementElement.prototype.description = function(definitions, xmlns) {

var elem = {};
definitions.descriptions.types[typeName] = elem;
var description = typeElement.description(definitions, xmlns);
if (typeof description === 'string') {
elem = description;
}
else {
Object.keys(description).forEach(function (key) {
elem[key] = description[key];
});
}

if (this.$ref) {
elem = element = typeElement.description(definitions, xmlns);
element = elem;
}
else {
elem = element[name] = typeElement.description(definitions, xmlns);
element[name] = elem;
}

if (typeof elem === 'object') {
Expand Down
17 changes: 17 additions & 0 deletions test/wsdl-parse-test.js
@@ -0,0 +1,17 @@
'use strict';

var path = require('path');
var open_wsdl = require('../lib/wsdl').open_wsdl;
var assert = require('assert');

describe(__filename, function () {
it('should parse recursive elements', function (done) {
open_wsdl(path.resolve(__dirname, 'wsdl/recursive.wsdl'), function (err, def) {
assert.equal(def.definitions.messages.operationRequest.parts['constraint[]'].expression,
def.definitions.messages.operationRequest.parts['constraint[]'].expression.expression);
assert.equal(def.definitions.messages.operationRequest.parts['constraint[]'].expression,
def.definitions.messages.operationRequest.parts['constraint[]'].expression.expression['constraint[]'].expression);
done();
});
});
});
99 changes: 99 additions & 0 deletions test/wsdl/recursive.wsdl
@@ -0,0 +1,99 @@
<wsdl:definitions name="OperationServiceNextGen" targetNamespace="http://some.schema.com/marketplace/search/v1/services" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://some.schema.com/marketplace/search/v1/services" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://some.schema.com/marketplace/search/v1/services">

<xs:simpleType name="AckValue">
<xs:restriction base="xs:string">
<xs:enumeration value="Success">
</xs:enumeration>
<xs:enumeration value="Failure">
</xs:enumeration>
<xs:enumeration value="Warning">
</xs:enumeration>
<xs:enumeration value="PartialFailure">
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:element name="operationRequest" type="tns:OperationRequest"/>
<xs:complexType name="OperationRequest">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="constraint" type="tns:Constraint">
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="operationResponse" type="tns:AckValue"/>
<xs:complexType name="Expression">
<xs:choice>
<xs:element maxOccurs="1" minOccurs="0" name="expression" type="tns:Expression">
</xs:element>
<xs:element maxOccurs="unbounded" minOccurs="0" name="constraint" type="tns:Constraint">
</xs:element>
</xs:choice>
</xs:complexType>
<xs:complexType name="Constraint">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="expression" type="tns:Expression">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="operationRequest">
<wsdl:part element="tns:operationRequest" name="params"/>
</wsdl:message>
<wsdl:message name="operationResponse">
<wsdl:part element="tns:operationResponse" name="params"/>
</wsdl:message>
<wsdl:portType name="OperationServiceNextGenPort">
<wsdl:operation name="operation">
<wsdl:documentation>
Documentation goes here.
</wsdl:documentation>
<wsdl:input message="tns:operationRequest"/>
<wsdl:output message="tns:operationResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="OperationServiceNextGenHttpBinding" type="tns:OperationServiceNextGenPort">

<http:binding verb="POST"/>
<wsdl:operation name="operation">

<http:operation location="/operation"/>
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded"/>


</wsdl:input>
<wsdl:output>
<mime:content type="text/xml"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="OperationServiceNextGenSOAPBinding" type="tns:OperationServiceNextGenPort">

<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="operation">

<soap:operation soapAction="http://some.schema.com/marketplace/search/v1/services/operation"/>
<wsdl:input>

<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>

<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="OperationServiceNextGen">
<wsdl:documentation>
<version>1.1.10</version>
</wsdl:documentation>
<wsdl:port binding="tns:OperationServiceNextGenHttpBinding" name="OperationServiceNextGenHttpPort">
<http:address location="https://svcs.ebay.com/services/search/v1/OperationServiceNextGen"/>
</wsdl:port>
<wsdl:port binding="tns:OperationServiceNextGenSOAPBinding" name="OperationServiceNextGenSOAPPort">
<soap12:address location="https://svcs.ebay.com/services/search/v1/OperationServiceNextGen"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

0 comments on commit 2b75e79

Please sign in to comment.