Skip to content

Commit

Permalink
Handle missing message definitions when creating SOAP client (#1241)
Browse files Browse the repository at this point in the history
  • Loading branch information
VinayakMohite4040 authored Jun 14, 2024
1 parent c40e5ea commit 4f0c065
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/wsdl/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -872,14 +872,16 @@ export class OperationElement extends Element {
}
const messageName = splitQName(child.$message).name;
const message = definitions.messages[messageName];
message.postProcess(definitions);
if (message.element) {
definitions.messages[message.element.$name] = message;
this[child.name] = message.element;
} else {
this[child.name] = message;
if (message) {
message.postProcess(definitions);
if (message.element) {
definitions.messages[message.element.$name] = message;
this[child.name] = message.element;
} else {
this[child.name] = message;
}
children.splice(i--, 1);
}
children.splice(i--, 1);
}
this.deleteFixedAttrs();
}
Expand Down
8 changes: 8 additions & 0 deletions test/wsdl-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,12 @@ describe('WSDL Parser (non-strict)', () => {
done();
});
});


it('Should create client even if the some of message definitions are missing', function (done) {
soap.createClient(__dirname+'/wsdl/missing_message_definition.wsdl', function(err, client) {
assert.equal(err, null);
done();
});
});
});
57 changes: 57 additions & 0 deletions test/wsdl/missing_message_definition.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://example.com/weather"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="WeatherService"
targetNamespace="http://example.com/weather">

<types>
<xsd:schema targetNamespace="http://example.com/weather">
<xsd:element name="GetWeatherRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="City" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetWeatherResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Temperature" type="xsd:float"/>
<xsd:element name="Conditions" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>

<message name="GetWeatherRequest">
<part name="parameters" element="tns:GetWeatherRequest"/>
</message>

<portType name="WeatherPortType">
<operation name="GetWeather">
<input message="tns:GetWeatherRequest"/>
<output message="tns:GetWeatherResponse"/>
</operation>
</portType>

<binding name="WeatherBinding" type="tns:WeatherPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetWeather">
<soap:operation soapAction="http://example.com/weather/GetWeather"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>

<service name="WeatherService">
<port name="WeatherPort" binding="tns:WeatherBinding">
<soap:address location="http://example.com/weather"/>
</port>
</service>
</definitions>

0 comments on commit 4f0c065

Please sign in to comment.