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

Handle Missing Message Definitions in WSDL for SOAP Client Creation #1241

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading