Skip to content

Commit caaabd0

Browse files
jglongaronw666
authored andcommitted
feature (xml key): allow in first level for rpc
1 parent 1c5c857 commit caaabd0

File tree

8 files changed

+126
-9
lines changed

8 files changed

+126
-9
lines changed

src/wsdl/index.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -604,17 +604,21 @@ export class WSDL {
604604
}
605605
if (key !== nsAttrName) {
606606
const value = params[key];
607-
const prefixedKey = (isParts ? '' : nsPrefix) + key;
608-
const attributes = [];
609-
if (typeof value === 'object' && value.hasOwnProperty(this.options.attributesKey)) {
610-
const attrs = value[this.options.attributesKey];
611-
for (const n in attrs) {
612-
attributes.push(' ' + n + '=' + '"' + attrs[n] + '"');
607+
if (key === this.options.xmlKey) {
608+
parts.push(this.objectToXML({[key]: value}, null, nsPrefix, nsURI));
609+
} else {
610+
const prefixedKey = (isParts ? '' : nsPrefix) + key;
611+
const attributes = [];
612+
if (typeof value === 'object' && value.hasOwnProperty(this.options.attributesKey)) {
613+
const attrs = value[this.options.attributesKey];
614+
for (const n in attrs) {
615+
attributes.push(' ' + n + '=' + '"' + attrs[n] + '"');
616+
}
613617
}
618+
parts.push(['<', prefixedKey].concat(attributes).concat('>').join(''));
619+
parts.push((typeof value === 'object') ? this.objectToXML(value, key, nsPrefix, nsURI) : xmlEscape(value));
620+
parts.push(['</', prefixedKey, '>'].join(''));
614621
}
615-
parts.push(['<', prefixedKey].concat(attributes).concat('>').join(''));
616-
parts.push((typeof value === 'object') ? this.objectToXML(value, key, nsPrefix, nsURI) : xmlEscape(value));
617-
parts.push(['</', prefixedKey, '>'].join(''));
618622
}
619623
}
620624
parts.push(['</', nsPrefix, name, '>'].join(''));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xs:schema xmlns:tns="http://www.Dummy.com/Common/Types" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.Dummy.com/Common/Types" elementFormDefault="qualified" attributeFormDefault="unqualified">
3+
<xs:complexType name="DummyResult">
4+
<xs:sequence>
5+
<xs:element name="DummyList" type="tns:DummyList" minOccurs="0"/>
6+
</xs:sequence>
7+
<xs:attribute name="code" type="xs:string" use="optional"/>
8+
</xs:complexType>
9+
<xs:complexType name="Dummy">
10+
<xs:simpleContent>
11+
<xs:extension base="xs:string">
12+
<xs:attribute name="language" type="xs:language" use="optional"/>
13+
</xs:extension>
14+
</xs:simpleContent>
15+
</xs:complexType>
16+
<xs:complexType name="DummyList">
17+
<xs:sequence>
18+
<xs:element name="DummyElement" type="tns:Dummy" maxOccurs="unbounded"/>
19+
</xs:sequence>
20+
</xs:complexType>
21+
</xs:schema>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xs:schema xmlns:tns="http://www.Dummy.com/Name/Types" xmlns:xs="http://www.w3.org/2001/XMLSchema"
3+
targetNamespace="http://www.Dummy.com/Name/Types" elementFormDefault="qualified"
4+
attributeFormDefault="unqualified" xmlns:c="http://www.Dummy.com/Common/Types">
5+
<xs:import namespace="common.xsd" schemaLocation="common.xsd"/>
6+
<xs:element name="DummyRequest">
7+
<xs:complexType>
8+
<xs:sequence>
9+
<xs:element name="DummyXML" type="xs:string" minOccurs="0"/>
10+
</xs:sequence>
11+
</xs:complexType>
12+
</xs:element>
13+
<xs:element name="DummyResponse">
14+
<xs:complexType>
15+
<xs:sequence>
16+
<xs:element name="DummyResult" type="c:DummyResult"/>
17+
</xs:sequence>
18+
</xs:complexType>
19+
</xs:element>
20+
</xs:schema>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"$xml": "<tns:DummyXML><myObject attr='myAttr'></myObject></tns:DummyXML>"
3+
}
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:tns="http://www.Dummy.com" xmlns:n="http://www.Dummy.com/Name/Types"><soap:Body><tns:Dummy><tns:DummyXML><myObject attr='myAttr'></myObject></tns:DummyXML></tns:Dummy></soap:Body></soap:Envelope>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"DummyResult": {
3+
"DummyList": {
4+
"DummyElement": {
5+
"attributes": {
6+
"language": "en-US"
7+
},
8+
"$value": "Dummy Element Entry"
9+
}
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://www.Dummy.com" xmlns:n="http://www.Dummy.com/Name/Types">
2+
<soap:Header></soap:Header>
3+
<soap:Body>
4+
<n:DummyResponse>
5+
<n:DummyResult>
6+
<c:DummyList xmlns:c="http://www.Dummy.com/Common/Types">
7+
<c:DummyElement language="en-US">
8+
Dummy Element Entry
9+
</c:DummyElement>
10+
</c:DummyList>
11+
</n:DummyResult>
12+
</n:DummyResponse>
13+
</soap:Body>
14+
</soap:Envelope>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
3+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
4+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
5+
xmlns:tns="http://www.Dummy.com" xmlns:n="http://www.Dummy.com/Name/Types" xmlns:ns="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://www.Dummy.com">
6+
<wsdl:types>
7+
<xs:schema>
8+
<xs:import namespace="http://www.Dummy.com/Common/Types" schemaLocation="common.xsd"/>
9+
<xs:import namespace="http://www.Dummy.com/Name/Types" schemaLocation="name.xsd"/>
10+
</xs:schema>
11+
</wsdl:types>
12+
<wsdl:message name="DummyRequest">
13+
<wsdl:part name="DummyRequest" element="n:DummyRequest"/>
14+
</wsdl:message>
15+
<wsdl:message name="DummyResponse">
16+
<wsdl:part name="DummyResponse" element="n:DummyResponse"/>
17+
</wsdl:message>
18+
<wsdl:portType name="DummyPortType">
19+
<wsdl:operation name="Dummy">
20+
<soap12:operation soapAction="" style="rpc"/>
21+
<wsdl:input message="tns:DummyRequest"/>
22+
<wsdl:output message="tns:DummyResponse"/>
23+
</wsdl:operation>
24+
</wsdl:portType>
25+
<wsdl:binding name="DummyBinding" type="tns:DummyPortType">
26+
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
27+
<wsdl:operation name="Dummy">
28+
<soap:operation soapAction="http://www.Dummy.com#Dummy" style="rpc"/>
29+
<wsdl:input>
30+
<soap:body use="literal"/>
31+
</wsdl:input>
32+
<wsdl:output>
33+
<soap:body use="literal"/>
34+
</wsdl:output>
35+
</wsdl:operation>
36+
</wsdl:binding>
37+
<wsdl:service name="DummyService">
38+
<wsdl:port name="DummyPortType" binding="tns:DummyBinding">
39+
<soap:address location="http://www.Dummy.com/"/>
40+
</wsdl:port>
41+
</wsdl:service>
42+
</wsdl:definitions>

0 commit comments

Comments
 (0)