Skip to content

Commit

Permalink
Fix including xsd from another xsd while using inline xmlns (#1202)
Browse files Browse the repository at this point in the history
  • Loading branch information
e6c31d authored Jul 17, 2024
1 parent 8d2519e commit 579ffc0
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/wsdl/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ export class ElementElement extends Element {
type = splitQName(type);
const typeName: string = type.name;
const ns: string = xmlns && xmlns[type.prefix] ||
this.xmlns[type.prefix] ||
((definitions.xmlns[type.prefix] !== undefined || definitions.xmlns[this.targetNSAlias] !== undefined) && this.schemaXmlns[type.prefix]) ||
definitions.xmlns[type.prefix];
const schema = definitions.schemas[ns];
Expand Down
9 changes: 9 additions & 0 deletions test/wsdl-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ describe('WSDL Parser (non-strict)', () => {
});
});

it('should load same namespace from included xsd with inline xmlns ', (done) => {
var expected = '{"DummyService":{"DummyPortType":{"Dummy":{"input":{"ID":"IdType|xs:string|pattern","Name":"NameType|xs:string|minLength,maxLength"},"output":{"Result":"dummy:DummyList"}}}}}';
soap.createClient(__dirname + '/wsdl/xsdinclude/xsd_include_inline_xmlns.wsdl', function(err, client) {
assert.ifError(err);
assert.equal(JSON.stringify(client.describe()), expected);
done();
});
});

it('should all attributes to root elements', (done) => {
var expectedMsg = '<ns1:fooRq xmlns:ns1="http://example.com/bar/xsd"' +
' xmlns="http://example.com/bar/xsd"><bar1:paymentRq bar1:test="attr"' +
Expand Down
22 changes: 22 additions & 0 deletions test/wsdl/xsdinclude/types_inline_xmlns.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.dummy.com/Types"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dummy="http://www.dummy.com/Types"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="types.xsd"/>
<xs:element name="DummyRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="ns1:IdType" xmlns:ns1="http://www.dummy.com/Types"/>
<xs:element name="Name" type="ns2:NameType" xmlns:ns2="http://www.dummy.com/Types"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="DummyResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="Result" type="dummy:DummyList"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
45 changes: 45 additions & 0 deletions test/wsdl/xsdinclude/xsd_include_inline_xmlns.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.dummy.com"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dummy="http://www.dummy.com/Types"
xmlns:tns="http://www.dummy.com">
<wsdl:types>
<xs:schema targetNamespace="http://www.dummy.com/Types"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dummy="http://www.dummy.com/Types"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="types_inline_xmlns.xsd"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="DummyRequest">
<wsdl:part name="DummyRequest" element="dummy:DummyRequest"/>
</wsdl:message>
<wsdl:message name="DummyResponse">
<wsdl:part name="DummyResponse" element="dummy:DummyResponse"/>
</wsdl:message>
<wsdl:portType name="DummyPortType">
<wsdl:operation name="Dummy">
<wsdl:input message="tns:DummyRequest"/>
<wsdl:output message="tns:DummyResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="DummyBinding" type="tns:DummyPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Dummy">
<soap:operation soapAction="tns#Dummy" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="DummyService">
<wsdl:port name="DummyPortType" binding="tns:DummyBinding">
<soap:address location="http://www.dummy.com/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

0 comments on commit 579ffc0

Please sign in to comment.