Skip to content
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
7 changes: 6 additions & 1 deletion src/wsdl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,12 @@ export class WSDL {
const topSchema = top.schema;
const name = splitQName(nsName).name;

if (typeof cur.schema === 'string' && (cur.schema === 'string' || cur.schema.split(':')[1] === 'string')) {
/**
* When parsing a string element, we need to correctly transform `<tag></tag>`
* to an empty string.
*/
const isStringElement = typeof cur.schema === 'string' && splitQName(cur.schema).name === 'string';
if (isStringElement) {
if (typeof obj === 'object' && Object.keys(obj).length === 0) {
obj = cur.object = this.options.preserveWhitespace ? cur.text || '' : '';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?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">
<soap:Body>
<DummyRequest xmlns="http://www.Dummy.com"></DummyRequest>
</soap:Body>
</soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"foo": {
"string_simple": "",
"string_pattern": "",
"string_simple_list": [""],
"string_pattern_list": [""]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://www.Dummy.com">
<soap:Body>
<tns:DummyResponse>
<tns:foo>
<tns:string_simple></tns:string_simple>
<tns:string_pattern></tns:string_pattern>
<tns:string_simple_list></tns:string_simple_list>
<tns:string_pattern_list></tns:string_pattern_list>
</tns:foo>
</tns:DummyResponse>
</soap:Body>
</soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?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"
targetNamespace="http://www.Dummy.com">

<wsdl:types>
<xs:schema targetNamespace="http://www.Dummy.com" elementFormDefault="qualified">
<xs:complexType name="ComplexType" abstract="false">
<xs:sequence>
<xs:element name="string_simple" minOccurs="1" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="string_pattern" minOccurs="1" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z0-9_ \-\+/\\\|\*=&lt;&gt;,.;:?!'`&quot;~@#$%^&amp;\(\)\[\]\{\}\r\n]{0,255}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="string_simple_list" minOccurs="0" maxOccurs="25">
<xs:simpleType>
<xs:restriction base="xs:string">
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="string_pattern_list" minOccurs="0" maxOccurs="25">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z0-9_ \-\+/\\\|\*=&lt;&gt;,.;:?!'`&quot;~@#$%^&amp;\(\)\[\]\{\}\r\n]{0,255}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>

<xs:element name="DummyRequest">
<xs:complexType>
<xs:sequence/>
</xs:complexType>
</xs:element>

<xs:element name="DummyResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="foo" type="tns:ComplexType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>

<wsdl:message name="DummyRequest">
<wsdl:part name="parameters" element="tns:DummyRequest"/>
</wsdl:message>
<wsdl:message name="DummyResponse">
<wsdl:part name="parameters" element="tns: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="Dummy"/>
<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="DummyPort" binding="tns:DummyBinding">
<soap:address location="http://localhost:1509/test"/>
</wsdl:port>
</wsdl:service>

</wsdl:definitions>