Skip to content

Commit cfb4497

Browse files
author
lah8789
committed
Changes to support the redefining of a namespace alias
within different elements. The provided WSDL was not serializing the response correctly when returning the XML. Created a request response folder to test the changes that were made and made sure code coverage remained the same.
1 parent 03d1f78 commit cfb4497

File tree

7 files changed

+125
-1
lines changed

7 files changed

+125
-1
lines changed

src/wsdl/elements.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -590,12 +590,19 @@ export class MessageElement extends Element {
590590
const ns = nsName.prefix;
591591
let schema = definitions.schemas[definitions.xmlns[ns]];
592592
this.element = schema.elements[nsName.name];
593+
let schemaToLookup;
594+
if (!this.element) {
595+
// Try to find it another way
596+
schemaToLookup = part.xmlns;
597+
schema = definitions.schemas[schemaToLookup[Object.keys(schemaToLookup)[0]]];
598+
this.element = schema.elements[nsName.name];
599+
}
593600
if (!this.element) {
594601
debug(nsName.name + ' is not present in wsdl and cannot be processed correctly.');
595602
return;
596603
}
597604
this.element.targetNSAlias = ns;
598-
this.element.targetNamespace = definitions.xmlns[ns];
605+
this.element.targetNamespace = (schemaToLookup && schemaToLookup.xsns) || definitions.xmlns[ns];
599606

600607
// set the optional $lookupType to be used within `client#_invoke()` when
601608
// calling `wsdl#objectToDocumentXML()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<xsd:schema targetNamespace="http://example.com/bar/xsd" elementFormDefault="qualified"
2+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3+
xmlns:bar="http://example.com/bar/xsd"
4+
xmlns:bar1="http://example.com/bar1/xsd">
5+
<xsd:import schemaLocation="bar1.xsd" namespace="http://example.com/bar1/xsd"/>
6+
<xsd:complexType name="Request1">
7+
<xsd:sequence minOccurs="0" maxOccurs="1">
8+
<xsd:element name="requestHeader" type="bar1:RequestHeader"/>
9+
</xsd:sequence>
10+
</xsd:complexType>
11+
<xsd:element name="Request1" type="bar:Request1" />
12+
<xsd:complexType name="Response1">
13+
<xsd:sequence minOccurs="0" maxOccurs="1">
14+
<xsd:element name="responseHeader" type="bar1:ResponseHeader"/>
15+
</xsd:sequence>
16+
</xsd:complexType>
17+
<xsd:element name="Response1" type="bar:Response1"/>
18+
</xsd:schema>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<xsd:schema targetNamespace="http://example.com/bar1/xsd" elementFormDefault="qualified" version="2.1.4"
2+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3+
xmlns:bar1="http://example.com/bar1/xsd">
4+
<xsd:simpleType name="UUID">
5+
<xsd:restriction base="xsd:string">
6+
<xsd:pattern value="[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}"/>
7+
</xsd:restriction>
8+
</xsd:simpleType>
9+
<xsd:complexType name="RequestHeader">
10+
<xsd:sequence>
11+
<xsd:element name="requestId" type="bar1:UUID" />
12+
</xsd:sequence>
13+
</xsd:complexType>
14+
<xsd:element name="RequestHeader" type="bar1:RequestHeader"/>
15+
<xsd:complexType name="ResponseHeader">
16+
<xsd:sequence>
17+
<xsd:element name="requestId" type="bar1:UUID" />
18+
</xsd:sequence>
19+
</xsd:complexType>
20+
<xsd:element name="ResponseHeader" type="bar1:ResponseHeader"/>
21+
<xsd:complexType name="ErrorInformation">
22+
<xsd:sequence>
23+
<xsd:element name="message" type="xsd:string"/>
24+
</xsd:sequence>
25+
</xsd:complexType>
26+
<xsd:element name="ErrorInformation" type="bar1:ErrorInformation"/>
27+
</xsd:schema>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"requestHeader": {
3+
"requestId": "79d9372c-d2fe-4f86-a637-d1f5710bb439"
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://example.com/foo/wsdl" xmlns:xsns="http://example.com/bar1/xsd"><soap:Body><Request1><requestHeader><requestId>79d9372c-d2fe-4f86-a637-d1f5710bb439</requestId></requestHeader></Request1></soap:Body></soap:Envelope>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope" xmlns:uba="http://example.com/bar1/xsd">
2+
<soapenv:Header/>
3+
<soapenv:Body>
4+
<cus:Response1 xmlns:cus="http://example.com/bar/xsd">
5+
<cus:responseHeader>
6+
<uba:requestId>79d9372c-d2fe-4f86-a637-d1f5710bb439</uba:requestId>
7+
</ns2:requestHeader>
8+
</cus:Request1>
9+
</soapenv:Body>
10+
</soapenv:Envelope>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<wsdl:definitions name="foo" targetNamespace="http://example.com/foo/wsdl"
3+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
4+
xmlns:ns0="http://example.com/foo/wsdl"
5+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
6+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
7+
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
8+
<wsdl:types>
9+
<xsd:schema>
10+
<xsd:import namespace="http://example.com/bar/xsd" schemaLocation="bar.xsd"/>
11+
<xsd:import namespace="http://example.com/bar1/xsd" schemaLocation="bar1.xsd"/>
12+
</xsd:schema>
13+
</wsdl:types>
14+
<wsdl:message name="ErrorInfo">
15+
<wsdl:part xmlns:xsns="http://example.com/bar1/xsd" name="ErrorInfo" element="xsns:ErrorInformation">
16+
</wsdl:part>
17+
</wsdl:message>
18+
<wsdl:message name="Request1">
19+
<wsdl:part xmlns:xsns="http://example.com/bar/xsd" name="Request1" element="xsns:Request1">
20+
</wsdl:part>
21+
</wsdl:message>
22+
<wsdl:message name="Response1">
23+
<wsdl:part xmlns:xsns="http://example.com/bar/xsd" name="Response1" element="xsns:Response1">
24+
</wsdl:part>
25+
</wsdl:message>
26+
<wsdl:portType name="foo_PortType">
27+
<wsdl:operation name="fooOp">
28+
<wsdl:input name="Request1" message="ns0:Request1">
29+
</wsdl:input>
30+
<wsdl:output name="Response1" message="ns0:Response1">
31+
</wsdl:output>
32+
<wsdl:fault name="ErrorResponseType" message="ns0:ErrorInfo">
33+
</wsdl:fault>
34+
</wsdl:operation>
35+
</wsdl:portType>
36+
<wsdl:binding name="foo_Binding" type="ns0:foo_PortType">
37+
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
38+
<wsdl:operation name="fooOp">
39+
<soap:operation style="document"/>
40+
<wsdl:input name="Request1">
41+
<soap:body use="literal"/>
42+
</wsdl:input>
43+
<wsdl:output name="Response1">
44+
<soap:body use="literal"/>
45+
</wsdl:output>
46+
<wsdl:fault name="ErrorResponseType">
47+
<soap:fault name="ErrorResponseType" use="literal"/>
48+
</wsdl:fault>
49+
</wsdl:operation>
50+
</wsdl:binding>
51+
<wsdl:service name="foo">
52+
<wsdl:port name="test_Port" binding="ns0:foo_Binding">
53+
<soap:address location="http://localhost:8888/mockfoo_Binding"/>
54+
</wsdl:port>
55+
</wsdl:service>
56+
</wsdl:definitions>

0 commit comments

Comments
 (0)