forked from vpulim/node-soap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve deserialization of inline simpleType declarations (vpulim#1015)
- Loading branch information
Showing
8 changed files
with
192 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
test/request-response-samples/Dummy__should_handle_inline_types/name.xsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xs:schema | ||
xmlns:tns="http://www.Dummy.com/Name/Types" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
targetNamespace="http://www.Dummy.com/Name/Types" | ||
> | ||
<xs:element name="DummyRequest" /> | ||
<xs:element name="DummyResponse"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="SimpleBoolean" type="xs:boolean" /> | ||
<xs:element name="InlineBoolean"> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:boolean" /> | ||
</xs:simpleType> | ||
</xs:element> | ||
<xs:element name="SimpleInt" type="xs:integer" /> | ||
<xs:element name="InlineInt"> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:integer"> | ||
<xs:minInclusive value="0" /> | ||
<xs:maxInclusive value="100" /> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:element> | ||
<xs:element name="SimpleDate" type="xs:date" /> | ||
<xs:element name="SimpleDateTime"> | ||
<xs:simpleType> | ||
<xs:restriction base="tns:DateTime"> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:element> | ||
<xs:element name="SimpleTimeHourMinute"> | ||
<xs:simpleType> | ||
<xs:restriction base="tns:TimeHourMinute"> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:element> | ||
<xs:element name="NamedNestedSimpleType"> | ||
<xs:simpleType name="NestedSimpleType"> | ||
<xs:restriction base="tns:TimeHourMinute"> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:element> | ||
<xs:element name="SimpleEnum"> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:integer"> | ||
<xs:enumeration value="0"/> | ||
<xs:enumeration value="1"/> | ||
<xs:enumeration value="2"/> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:element> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
<xs:simpleType name="TimeHourMinute"> | ||
<xs:restriction base="xs:string"> | ||
<xs:pattern value="(([0-9]{2}(:))[0-9]{2})"/> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
<xs:simpleType name="DateTime"> | ||
<xs:restriction base="xs:string"> | ||
<xs:pattern value="(((([0-9]{4}(\-))[0-9]{2})(\-))[0-9]{2})"/> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
|
||
</xs:schema> |
2 changes: 2 additions & 0 deletions
2
test/request-response-samples/Dummy__should_handle_inline_types/request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
12 changes: 12 additions & 0 deletions
12
test/request-response-samples/Dummy__should_handle_inline_types/request.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?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> | ||
<n:DummyRequest xmlns:n="http://www.Dummy.com/Name/Types"> | ||
</n:DummyRequest> | ||
</soap:Body> | ||
</soap:Envelope> |
11 changes: 11 additions & 0 deletions
11
test/request-response-samples/Dummy__should_handle_inline_types/response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"SimpleBoolean": true, | ||
"InlineBoolean": true, | ||
"SimpleInt": 4, | ||
"InlineInt": 4, | ||
"SimpleDate": "2018-07-21T00:00:00.000Z", | ||
"SimpleDateTime": "2018-07-21T00:00:00.000Z", | ||
"SimpleTimeHourMinute": 150, | ||
"NamedNestedSimpleType": 240, | ||
"SimpleEnum": 2 | ||
} |
20 changes: 20 additions & 0 deletions
20
test/request-response-samples/Dummy__should_handle_inline_types/response.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<soap:Envelope | ||
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" | ||
xmlns:tns="http://www.Dummy.com" | ||
xmlns:n="http://www.Dummy.com/Name/Types" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<soap:Header></soap:Header> | ||
<soap:Body> | ||
<n:DummyResponse> | ||
<n:SimpleBoolean>true</n:SimpleBoolean> | ||
<n:InlineBoolean>true</n:InlineBoolean> | ||
<n:SimpleInt>4</n:SimpleInt> | ||
<n:InlineInt>4</n:InlineInt> | ||
<n:SimpleDate>2018-07-21</n:SimpleDate> | ||
<n:SimpleDateTime>2018-07-21</n:SimpleDateTime> | ||
<n:SimpleTimeHourMinute>02:30</n:SimpleTimeHourMinute> | ||
<n:NamedNestedSimpleType>04:00</n:NamedNestedSimpleType> | ||
<n:SimpleEnum>2</n:SimpleEnum> | ||
</n:DummyResponse> | ||
</soap:Body> | ||
</soap:Envelope> |
40 changes: 40 additions & 0 deletions
40
test/request-response-samples/Dummy__should_handle_inline_types/soap.wsdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" | ||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
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"> | ||
<wsdl:types> | ||
<xs:schema> | ||
<xs:import namespace="http://www.Dummy.com/Name/Types" schemaLocation="name.xsd"/> | ||
</xs:schema> | ||
</wsdl:types> | ||
<wsdl:message name="DummyRequest"> | ||
<wsdl:part name="DummyRequest" element="n:DummyRequest"/> | ||
</wsdl:message> | ||
<wsdl:message name="DummyResponse"> | ||
<wsdl:part name="DummyResponse" element="n: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="http://www.Dummy.com#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> |
13 changes: 13 additions & 0 deletions
13
test/request-response-samples/Dummy__should_handle_inline_types/wsdl_options.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
exports.customDeserializer = { | ||
DateTime: (text) => new Date(text), | ||
TimeHourMinute: (text) => { | ||
// Return number of minutes since midnight | ||
const results = text.split(':').map(t => parseInt(t, 10)); | ||
return results[0] * 60 + results[1]; | ||
}, | ||
NestedSimpleType: (text) => { | ||
// Return number of minutes since midnight | ||
const results = text.split(':').map(t => parseInt(t, 10)); | ||
return results[0] * 60 + results[1]; | ||
} | ||
}; |