Skip to content

Commit

Permalink
Merge pull request vpulim#789 from tobias-neubert/master
Browse files Browse the repository at this point in the history
Children may be empty resulting in a NPE
  • Loading branch information
jsdevel committed Feb 4, 2016
2 parents 64fc9fd + f8f982e commit 09dc14f
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/wsdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,18 +726,20 @@ BindingElement.prototype.postProcess = function(definitions) {
ServiceElement.prototype.postProcess = function(definitions) {
var children = this.children,
bindings = definitions.bindings;
for (var i = 0, child; child = children[i]; i++) {
if (child.name !== 'port')
continue;
var bindingName = splitQName(child.$binding).name;
var binding = bindings[bindingName];
if (binding) {
binding.postProcess(definitions);
this.ports[child.$name] = {
location: child.location,
binding: binding
};
children.splice(i--, 1);
if (children && children.length > 0) {
for (var i = 0, child; child = children[i]; i++) {
if (child.name !== 'port')
continue;
var bindingName = splitQName(child.$binding).name;
var binding = bindings[bindingName];
if (binding) {
binding.postProcess(definitions);
this.ports[child.$name] = {
location: child.location,
binding: binding
};
children.splice(i--, 1);
}
}
}
delete this.$name;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/wsdl-viewer.xsl"?>
<wsdl:definitions xmlns:foo="http://fo.bar/doIt/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="doIt" targetNamespace="http://foo.bar/doIt">

<wsdl:portType name="doIt">
<wsdl:operation name="doItMan"/>
</wsdl:portType>

<wsdl:binding name="doItSOAP" type="foo:doIt">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="doIt">
<soap:operation soapAction="" />
</wsdl:operation>
</wsdl:binding>

<wsdl:service name="doIt">
<wsdl:port binding="auth:doItSOAP" name="doItSOAP">
<soap:address location="https://foo.bar/services/doIt/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"userCredentials": {
"username": "beeblebrox",
"sessionid": "42"
},
"getAvailabilityRequest": {
"attributes": {
"currency": "EUR"
},
"departure": "HAM",
"destination": "FRA",
"flightDate": "2016-01-01",
"returnDate": "2016-02-01",
"paxCount": [
{
"attributes": {
"count": 1,
"paxType": "ADT"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header/><soap:Body><userCredentials><username>beeblebrox</username><sessionid>42</sessionid></userCredentials><getAvailabilityRequest currency="EUR"><departure>HAM</departure><destination>FRA</destination><flightDate>2016-01-01</flightDate><returnDate>2016-02-01</returnDate><paxCount count="1" paxType="ADT"/></getAvailabilityRequest></soap:Body></soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/wsdl-viewer.xsl"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:foo="http://foo.bar/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:partner="http://foo.bar/partner/" targetNamespace="http://foo.bar/partner/" name="partner">
<wsdl:import namespace="http://foo.bar/doIt/" location="imported.wsdl"/>
<wsdl:types>
<xsd:schema targetNamespace="http://foo.bar/partner/">
<xsd:complexType name="GetAvailabilityRequest">
<xsd:sequence>
<xsd:element name="departure" type="xsd:string" maxOccurs="1" minOccurs="1"/>

</xsd:sequence>
<xsd:attribute name="currency" type="xsd:string" use="optional"/>
</xsd:complexType>

<xsd:complexType name="GetAvailabilityResponse">
<xsd:sequence>
<xsd:element name="vacancy" type="xsd:string" maxOccurs="1" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getAvailabilityRequest">
<wsdl:part name="getAvailabilityRequest" type="partner:GetAvailabilityRequest"/>
</wsdl:message>
<wsdl:message name="getAvailabilityResponse">
<wsdl:part name="getAvailabilityResponse" type="partner:GetAvailabilityResponse"/>
</wsdl:message>

<wsdl:portType name="partnerGetAvailabilityPortType">
<wsdl:operation name="getAvailability">
<wsdl:input message="partner:getAvailabilityRequest"/>
<wsdl:output message="partner:getAvailabilityResponse"/>
</wsdl:operation>
</wsdl:portType>

<wsdl:binding name="partnerGetAvailabilityBinding" type="partner:partnerGetAvailabilityPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getAvailability">
<soap:operation soapAction=""/>
<wsdl:input>
<soap:body use="literal" namespace="http://foo.bar/partner/"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="http://foo.bar/partner/"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>

<wsdl:service name="partner">
<wsdl:port binding="partner:partnerGetAvailabilityBinding" name="partnerGetAvailabilityPort">
<soap:address location="https://foo.bar/services/090/partner/getAvailability/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

0 comments on commit 09dc14f

Please sign in to comment.