1import io
2
3import pytest
4from lxml import etree
5
6from tests.utils import DummyTransport, assert_nodes_equal, load_xml, render_node
7from zeep import xsd
8
9
10@pytest.fixture(scope="function")
11def transport():
12    transport = DummyTransport()
13    transport.bind(
14        "http://schemas.xmlsoap.org/soap/encoding/",
15        load_xml(io.open("tests/wsdl_files/soap-enc.xsd", "r").read().encode("utf-8")),
16    )
17    return transport
18
19
20def test_simple_type(transport):
21    schema = xsd.Schema(
22        load_xml(
23            """
24    <xsd:schema
25        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
26        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
27        xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
28        targetNamespace="http://tests.python-zeep.org/tns">
29      <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
30      <xsd:complexType name="ArrayOfString">
31        <xsd:complexContent>
32          <xsd:restriction base="SOAP-ENC:Array">
33            <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]"/>
34          </xsd:restriction>
35        </xsd:complexContent>
36      </xsd:complexType>
37    </xsd:schema>
38    """
39        ),
40        transport=transport,
41    )
42
43    ArrayOfString = schema.get_type("ns0:ArrayOfString")
44    print(ArrayOfString.__dict__)
45
46    value = ArrayOfString(["item", "and", "even", "more", "items"])
47
48    node = etree.Element("document")
49    ArrayOfString.render(node, value)
50
51    expected = """
52        <document>
53            <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">item</item>
54            <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">and</item>
55            <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">even</item>
56            <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">more</item>
57            <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">items</item>
58        </document>
59    """  # noqa
60
61    assert_nodes_equal(expected, node)
62
63    data = ArrayOfString.parse_xmlelement(node, schema)
64    assert data == ["item", "and", "even", "more", "items"]
65    assert data.as_value_object()
66
67
68def test_simple_type_nested(transport):
69    schema = xsd.Schema(
70        load_xml(
71            """
72    <xsd:schema
73        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
74        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
75        xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
76        targetNamespace="http://tests.python-zeep.org/tns"
77        xmlns:tns="http://tests.python-zeep.org/tns">
78      <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
79      <xsd:complexType name="container">
80        <xsd:sequence>
81          <xsd:element name="strings" type="tns:ArrayOfString"/>
82        </xsd:sequence>
83      </xsd:complexType>
84
85      <xsd:complexType name="ArrayOfString">
86        <xsd:complexContent>
87          <xsd:restriction base="SOAP-ENC:Array">
88            <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]"/>
89          </xsd:restriction>
90        </xsd:complexContent>
91      </xsd:complexType>
92    </xsd:schema>
93    """
94        ),
95        transport=transport,
96    )
97
98    Container = schema.get_type("ns0:container")
99    value = Container(strings=["item", "and", "even", "more", "items"])
100
101    assert value.strings == ["item", "and", "even", "more", "items"]
102
103    node = etree.Element("document")
104    Container.render(node, value)
105
106    expected = """
107        <document>
108            <strings>
109              <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">item</item>
110              <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">and</item>
111              <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">even</item>
112              <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">more</item>
113              <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">items</item>
114            </strings>
115        </document>
116    """  # noqa
117
118    assert_nodes_equal(expected, node)
119
120    data = Container.parse_xmlelement(node, schema)
121    assert data.strings == ["item", "and", "even", "more", "items"]
122
123
124def test_simple_type_nested_inline_type(transport):
125    schema = xsd.Schema(
126        load_xml(
127            """
128    <xsd:schema
129        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
130        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
131        xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
132        targetNamespace="http://tests.python-zeep.org/tns"
133        xmlns:tns="http://tests.python-zeep.org/tns">
134      <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
135      <xsd:complexType name="container">
136        <xsd:sequence>
137          <xsd:element name="strings" type="tns:ArrayOfString"/>
138        </xsd:sequence>
139      </xsd:complexType>
140
141      <xsd:complexType name="ArrayOfString">
142        <xsd:complexContent>
143          <xsd:restriction base="SOAP-ENC:Array">
144            <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]"/>
145          </xsd:restriction>
146        </xsd:complexContent>
147      </xsd:complexType>
148    </xsd:schema>
149    """
150        ),
151        transport=transport,
152    )
153
154    Container = schema.get_type("ns0:container")
155    node = load_xml(
156        """
157        <document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
158            <strings xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
159              <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">item</item>
160              <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">and</item>
161              <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">even</item>
162              <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">more</item>
163              <item xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">items</item>
164            </strings>
165        </document>
166    """
167    )  # noqa
168
169    data = Container.parse_xmlelement(node, schema)
170    assert data.strings == ["item", "and", "even", "more", "items"]
171
172
173def test_complex_type(transport):
174    schema = xsd.Schema(
175        load_xml(
176            """
177    <xsd:schema
178        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
179        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
180        xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
181        xmlns:tns="http://tests.python-zeep.org/tns"
182        targetNamespace="http://tests.python-zeep.org/tns">
183      <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
184
185      <xsd:complexType name="ArrayObject">
186        <xsd:sequence>
187          <xsd:element name="attr_1" type="xsd:string"/>
188          <xsd:element name="attr_2" type="xsd:string"/>
189        </xsd:sequence>
190      </xsd:complexType>
191      <xsd:complexType name="ArrayOfObject">
192        <xsd:complexContent>
193          <xsd:restriction base="SOAP-ENC:Array">
194            <xsd:sequence>
195              <xsd:element name="obj" type="tns:ArrayObject" minOccurs="0" maxOccurs="unbounded"/>
196            </xsd:sequence>
197            <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:ArrayObject[]"/>
198          </xsd:restriction>
199        </xsd:complexContent>
200      </xsd:complexType>
201    </xsd:schema>
202    """
203        ),
204        transport=transport,
205    )
206
207    ArrayOfObject = schema.get_type("ns0:ArrayOfObject")
208    ArrayObject = schema.get_type("ns0:ArrayObject")
209
210    value = ArrayOfObject(
211        [
212            ArrayObject(attr_1="attr-1", attr_2="attr-2"),
213            ArrayObject(attr_1="attr-3", attr_2="attr-4"),
214            ArrayObject(attr_1="attr-5", attr_2="attr-6"),
215        ]
216    )
217
218    node = etree.Element("document")
219    ArrayOfObject.render(node, value)
220
221    expected = """
222        <document>
223            <obj>
224                <attr_1>attr-1</attr_1>
225                <attr_2>attr-2</attr_2>
226            </obj>
227            <obj>
228                <attr_1>attr-3</attr_1>
229                <attr_2>attr-4</attr_2>
230            </obj>
231            <obj>
232                <attr_1>attr-5</attr_1>
233                <attr_2>attr-6</attr_2>
234            </obj>
235        </document>
236    """
237    assert_nodes_equal(expected, node)
238    data = ArrayOfObject.parse_xmlelement(node, schema)
239
240    assert data[0].attr_1 == "attr-1"
241    assert data[0].attr_2 == "attr-2"
242    assert data[1].attr_1 == "attr-3"
243    assert data[1].attr_2 == "attr-4"
244    assert data[2].attr_1 == "attr-5"
245    assert data[2].attr_2 == "attr-6"
246
247
248def test_complex_type_without_name(transport):
249    schema = xsd.Schema(
250        load_xml(
251            """
252    <xsd:schema
253        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
254        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
255        xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
256        xmlns:tns="http://tests.python-zeep.org/tns"
257        targetNamespace="http://tests.python-zeep.org/tns">
258      <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
259
260      <xsd:complexType name="ArrayObject">
261        <xsd:sequence>
262          <xsd:element name="attr_1" type="xsd:string"/>
263          <xsd:element name="attr_2" type="xsd:string"/>
264        </xsd:sequence>
265      </xsd:complexType>
266      <xsd:complexType name="ArrayOfObject">
267        <xsd:complexContent>
268          <xsd:restriction base="SOAP-ENC:Array">
269            <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:ArrayObject[]"/>
270          </xsd:restriction>
271        </xsd:complexContent>
272      </xsd:complexType>
273    </xsd:schema>
274    """
275        ),
276        transport=transport,
277    )
278
279    ArrayOfObject = schema.get_type("ns0:ArrayOfObject")
280    ArrayObject = schema.get_type("ns0:ArrayObject")
281
282    value = ArrayOfObject(
283        [
284            ArrayObject(attr_1="attr-1", attr_2="attr-2"),
285            ArrayObject(attr_1="attr-3", attr_2="attr-4"),
286            ArrayObject(attr_1="attr-5", attr_2="attr-6"),
287        ]
288    )
289
290    node = etree.Element("document")
291    ArrayOfObject.render(node, value)
292
293    expected = """
294        <document>
295            <ArrayObject>
296                <attr_1>attr-1</attr_1>
297                <attr_2>attr-2</attr_2>
298            </ArrayObject>
299            <ArrayObject>
300                <attr_1>attr-3</attr_1>
301                <attr_2>attr-4</attr_2>
302            </ArrayObject>
303            <ArrayObject>
304                <attr_1>attr-5</attr_1>
305                <attr_2>attr-6</attr_2>
306            </ArrayObject>
307        </document>
308    """
309    assert_nodes_equal(expected, node)
310    data = ArrayOfObject.parse_xmlelement(node, schema)
311
312    assert len(data) == 3
313    assert data[0]["attr_1"] == "attr-1"
314    assert data[0]["attr_2"] == "attr-2"
315    assert data[1]["attr_1"] == "attr-3"
316    assert data[1]["attr_2"] == "attr-4"
317    assert data[2]["attr_1"] == "attr-5"
318    assert data[2]["attr_2"] == "attr-6"
319
320
321def test_soap_array_parse_remote_ns():
322    transport = DummyTransport()
323    transport.bind(
324        "http://schemas.xmlsoap.org/soap/encoding/",
325        load_xml(io.open("tests/wsdl_files/soap-enc.xsd", "r").read().encode("utf-8")),
326    )
327
328    schema = xsd.Schema(
329        load_xml(
330            """
331        <?xml version="1.0"?>
332        <xsd:schema
333          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
334          xmlns:tns="http://tests.python-zeep.org/"
335          xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
336          xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
337          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
338          targetNamespace="http://tests.python-zeep.org/"
339          elementFormDefault="qualified">
340          <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
341          <xsd:simpleType name="CountryCodeType">
342            <xsd:restriction base="xsd:string">
343              <xsd:length value="2"/>
344              <xsd:pattern value="[a-zA-Z]{2}"/>
345            </xsd:restriction>
346          </xsd:simpleType>
347          <xsd:complexType name="CountryItemType">
348            <xsd:sequence>
349              <xsd:element name="code" type="tns:CountryCodeType"/>
350              <xsd:element name="name" type="xsd:string"/>
351            </xsd:sequence>
352          </xsd:complexType>
353          <xsd:complexType name="CountriesArrayType">
354            <xsd:complexContent>
355              <xsd:restriction base="soapenc:Array">
356                <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="tns:CountryItemType[]"/>
357              </xsd:restriction>
358            </xsd:complexContent>
359          </xsd:complexType>
360          <xsd:element name="countries" type="tns:CountriesArrayType"/>
361        </xsd:schema>
362    """
363        ),
364        transport,
365    )
366
367    doc = load_xml(
368        """
369      <countries
370            SOAP-ENC:arrayType="ns1:CountryItemType[1]"
371            xsi:type="ns1:CountriesArrayType"
372            xmlns:ns1="http://tests.python-zeep.org/"
373            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
374            xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
375          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
376        <item xsi:type="ns1:CountryItemType">
377          <code xsi:type="ns1:CountryCodeType">NL</code>
378          <name xsi:type="xsd:string">The Netherlands</name>
379        </item>
380      </countries>
381    """
382    )
383
384    elm = schema.get_element("ns0:countries")
385    data = elm.parse(doc, schema)
386
387    assert data[0].code == "NL"
388    assert data[0].name == "The Netherlands"
389
390
391def test_wsdl_array_type():
392    transport = DummyTransport()
393    transport.bind(
394        "http://schemas.xmlsoap.org/soap/encoding/",
395        load_xml(io.open("tests/wsdl_files/soap-enc.xsd", "r").read().encode("utf-8")),
396    )
397
398    schema = xsd.Schema(
399        load_xml(
400            """
401        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
402                    xmlns:tns="http://tests.python-zeep.org/"
403                    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
404                    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
405                    targetNamespace="http://tests.python-zeep.org/"
406                    elementFormDefault="qualified">
407          <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
408          <xsd:complexType name="array">
409            <xsd:complexContent>
410              <xsd:restriction base="SOAP-ENC:Array">
411                <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:base[]"/>
412              </xsd:restriction>
413            </xsd:complexContent>
414          </xsd:complexType>
415          <xsd:complexType name="base">
416            <xsd:sequence>
417              <xsd:element minOccurs="0" name="item_1" type="xsd:string"/>
418              <xsd:element minOccurs="0" name="item_2" type="xsd:string"/>
419            </xsd:sequence>
420          </xsd:complexType>
421          <xsd:element name="array" type="tns:array"/>
422        </xsd:schema>
423    """
424        ),
425        transport,
426    )
427    array_elm = schema.get_element("{http://tests.python-zeep.org/}array")
428
429    item_type = schema.get_type("{http://tests.python-zeep.org/}base")
430    item_1 = item_type(item_1="foo_1", item_2="bar_1")
431    item_2 = item_type(item_1="foo_2", item_2="bar_2")
432
433    # array = array_elm([
434    #     xsd.AnyObject(item_type, item_1),
435    #     xsd.AnyObject(item_type, item_2),
436    # ])
437
438    array = array_elm([item_1, item_2])
439    node = etree.Element("document")
440    assert array_elm.signature(schema=schema) == "ns0:array(ns0:array)"
441
442    array_type = schema.get_type("ns0:array")
443    assert array_type.signature(schema=schema) == (
444        "ns0:array(_value_1: base[], arrayType: xsd:string, "
445        + "offset: ns1:arrayCoordinate, id: xsd:ID, href: xsd:anyURI, _attr_1: {})"
446    )
447    array_elm.render(node, array)
448    expected = """
449        <document>
450            <ns0:array xmlns:ns0="http://tests.python-zeep.org/">
451                <base>
452                    <ns0:item_1>foo_1</ns0:item_1>
453                    <ns0:item_2>bar_1</ns0:item_2>
454                </base>
455                <base>
456                    <ns0:item_1>foo_2</ns0:item_1>
457                    <ns0:item_2>bar_2</ns0:item_2>
458                </base>
459            </ns0:array>
460        </document>
461    """
462    assert_nodes_equal(expected, node)
463
464
465def test_soap_array_parse():
466    transport = DummyTransport()
467    transport.bind(
468        "http://schemas.xmlsoap.org/soap/encoding/",
469        load_xml(io.open("tests/wsdl_files/soap-enc.xsd", "r").read().encode("utf-8")),
470    )
471
472    schema = xsd.Schema(
473        load_xml(
474            """
475    <?xml version="1.0"?>
476    <schema xmlns="http://www.w3.org/2001/XMLSchema"
477            xmlns:tns="http://tests.python-zeep.org/"
478            xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
479            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
480            targetNamespace="http://tests.python-zeep.org/"
481            elementFormDefault="qualified">
482      <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
483      <complexType name="FlagDetailsStruct">
484          <sequence>
485              <element name="Name">
486                  <simpleType>
487                      <restriction base="string">
488                          <maxLength value="512"/>
489                      </restriction>
490                  </simpleType>
491              </element>
492              <element name="Value" type="string"/>
493          </sequence>
494      </complexType>
495      <complexType name="FlagDetailsList">
496          <complexContent>
497              <restriction base="soapenc:Array">
498                  <sequence>
499                      <element
500                        name="FlagDetailsStruct" type="tns:FlagDetailsStruct"
501                        minOccurs="0" maxOccurs="unbounded"/>
502                  </sequence>
503                  <attribute ref="soapenc:arrayType" use="required"/>
504              </restriction>
505          </complexContent>
506      </complexType>
507      <element name="FlagDetailsList" type="tns:FlagDetailsList"/>
508    </schema>
509    """
510        ),
511        transport,
512    )
513
514    doc = load_xml(
515        """
516         <FlagDetailsList xmlns="http://tests.python-zeep.org/">
517            <FlagDetailsStruct>
518               <Name>flag1</Name>
519               <Value>value1</Value>
520            </FlagDetailsStruct>
521            <FlagDetailsStruct>
522               <Name>flag2</Name>
523               <Value>value2</Value>
524            </FlagDetailsStruct>
525         </FlagDetailsList>
526    """
527    )
528
529    elm = schema.get_element("ns0:FlagDetailsList")
530    data = elm.parse(doc, schema)
531    assert data[0].Name == "flag1"
532    assert data[0].Value == "value1"
533    assert data[1].Name == "flag2"
534    assert data[1].Value == "value2"
535
536
537def test_xml_soap_enc_string(transport):
538    schema = xsd.Schema(
539        load_xml(
540            """
541        <?xml version="1.0"?>
542        <xsd:schema
543            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
544            xmlns:tns="http://tests.python-zeep.org/"
545            xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
546            xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
547            targetNamespace="http://tests.python-zeep.org/"
548            elementFormDefault="qualified">
549          <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
550
551          <xsd:element name="value" type="tns:ArrayOfString"/>
552
553          <xsd:complexType name="ArrayOfString">
554            <xsd:complexContent>
555              <xsd:restriction base="soapenc:Array">
556                <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="soapenc:string[]"/>
557              </xsd:restriction>
558            </xsd:complexContent>
559          </xsd:complexType>
560
561        </xsd:schema>
562    """
563        ),
564        transport,
565    )
566    shoe_type = schema.get_element("{http://tests.python-zeep.org/}value")
567
568    obj = shoe_type(["foo"])
569    node = render_node(shoe_type, obj)
570    expected = """
571        <document>
572            <ns0:value xmlns:ns0="http://tests.python-zeep.org/">
573              <string>foo</string>
574            </ns0:value>
575        </document>
576    """
577    assert_nodes_equal(expected, node)
578
579    obj = shoe_type.parse(node[0], schema)
580    assert obj[0]["_value_1"] == "foo"
581
582    # Via string-types
583    string_type = schema.get_type("{http://schemas.xmlsoap.org/soap/encoding/}string")
584    obj = shoe_type([string_type("foo")])
585    node = render_node(shoe_type, obj)
586    expected = """
587        <document>
588            <ns0:value xmlns:ns0="http://tests.python-zeep.org/">
589              <string>foo</string>
590            </ns0:value>
591        </document>
592    """
593    assert_nodes_equal(expected, node)
594
595    obj = shoe_type.parse(node[0], schema)
596    assert obj[0]["_value_1"] == "foo"
597
598    # Via dicts
599    string_type = schema.get_type("{http://schemas.xmlsoap.org/soap/encoding/}string")
600    obj = shoe_type([{"_value_1": "foo"}])
601    node = render_node(shoe_type, obj)
602    expected = """
603        <document>
604            <ns0:value xmlns:ns0="http://tests.python-zeep.org/">
605              <string>foo</string>
606            </ns0:value>
607        </document>
608    """
609    assert_nodes_equal(expected, node)
610
611    obj = shoe_type.parse(node[0], schema)
612    assert obj[0]["_value_1"] == "foo"
613