How to use the zeep.xsd.AnyObject function in zeep

To help you get started, we’ve selected a few zeep examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mvantellingen / python-zeep / tests / test_xsd_any.py View on Github external
"""
        )
    )

    item_elm = schema.get_element("{http://tests.python-zeep.org/}item")
    assert isinstance(item_elm.type, xsd.String)

    container_elm = schema.get_element("{http://tests.python-zeep.org/}container")
    obj = container_elm(
        item="bar",
        _value_1=xsd.AnyObject(item_elm, item_elm("argh")),
        _value_2=xsd.AnyObject(item_elm, item_elm("ok")),
    )

    node = etree.Element("document")
    container_elm.render(node, obj)
    expected = """
        
            
                bar
                argh
                ok
            
        
    """
    assert_nodes_equal(expected, node)
    item = container_elm.parse(list(node)[0], schema)
github mvantellingen / python-zeep / tests / test_xsd_complex_types.py View on Github external
),
    )

    Map = xsd.ComplexType(
        xsd.Sequence(
            [xsd.Element("item", xsd.AnyType(), min_occurs=1, max_occurs="unbounded")]
        ),
        qname=etree.QName("{http://xml.apache.org/xml-soap}Map"),
    )

    header_Username = KeyValueData(
        xsd.AnyObject(xsd.String(), "Username"),
        value=xsd.AnyObject(xsd.String(), "abc"),
    )
    header_ShopId = KeyValueData(
        xsd.AnyObject(xsd.String(), "ShopId"), value=xsd.AnyObject(xsd.Int(), 123)
    )
    auth = Map(item=[header_Username, header_ShopId])

    header_LimitNum = KeyValueData(
        xsd.AnyObject(xsd.String(), "LimitNum"), value=xsd.AnyObject(xsd.Int(), 2)
    )
    params = Map(item=[header_LimitNum])

    container = schema.get_element("ns0:container")
    obj = container(auth=auth, params=params)

    result = render_node(container, obj)
    expected = load_xml(
        """
    
github mvantellingen / python-zeep / tests / test_xsd_any.py View on Github external
"""
        )
    )

    item_elm = schema.get_element("{http://tests.python-zeep.org/}item")
    assert isinstance(item_elm.type, xsd.String)

    container_elm = schema.get_element("{http://tests.python-zeep.org/}container")
    obj = container_elm(
        item="bar",
        _value_1=xsd.AnyObject(item_elm, item_elm("argh")),
        _value_2=xsd.AnyObject(item_elm, item_elm("ok")),
    )

    node = etree.Element("document")
    container_elm.render(node, obj)
    expected = """
        
            
                bar
                argh
                ok
            
        
    """
    assert_nodes_equal(expected, node)
    item = container_elm.parse(list(node)[0], schema)
    assert item.item == "bar"
github mvantellingen / python-zeep / tests / test_xsd_indicators_choice.py View on Github external
<element name="item_2">
                      
                    
                  
                
            
          </element>
        
    """
        )
    )

    element = schema.get_element("ns0:container")
    value = element(
        item_2="item-2",
        _value_1=[xsd.AnyObject(schema.get_element("ns0:item_any"), "any-content")],
    )

    expected = """
        
          
            item-2
            any-content
          
        
    """
    node = render_node(element, value)
    assert_nodes_equal(node, expected)
    result = element.parse(node[0], schema)
    assert result.item_2 == "item-2"
    assert result._value_1 == ["any-content"]
github mvantellingen / python-zeep / tests / test_xsd_indicators_choice.py View on Github external
""".strip()
    )
    schema = xsd.Schema(node)
    element = schema.get_element("ns0:container")
    item_1 = schema.get_element("ns0:item_1")
    any_object = xsd.AnyObject(item_1, item_1("foo"))
    value = element(_value_1=[any_object], name="foo", something="bar")

    expected = """
      
        
          foo
        
      
    """
    node = etree.Element("document")
    element.render(node, value)
    assert_nodes_equal(expected, node)

    result = element.parse(node[0], schema)
    assert result.name == "foo"
    assert result.something is True
github mvantellingen / python-zeep / tests / test_xsd_complex_types.py View on Github external
xsd.Sequence(
                [xsd.Element("key", xsd.AnyType()), xsd.Element("value", xsd.AnyType())]
            )
        ),
    )

    Map = xsd.ComplexType(
        xsd.Sequence(
            [xsd.Element("item", xsd.AnyType(), min_occurs=1, max_occurs="unbounded")]
        ),
        qname=etree.QName("{http://xml.apache.org/xml-soap}Map"),
    )

    header_Username = KeyValueData(
        xsd.AnyObject(xsd.String(), "Username"),
        value=xsd.AnyObject(xsd.String(), "abc"),
    )
    header_ShopId = KeyValueData(
        xsd.AnyObject(xsd.String(), "ShopId"), value=xsd.AnyObject(xsd.Int(), 123)
    )
    auth = Map(item=[header_Username, header_ShopId])

    header_LimitNum = KeyValueData(
        xsd.AnyObject(xsd.String(), "LimitNum"), value=xsd.AnyObject(xsd.Int(), 2)
    )
    params = Map(item=[header_LimitNum])

    container = schema.get_element("ns0:container")
    obj = container(auth=auth, params=params)

    result = render_node(container, obj)
    expected = load_xml(
github mvantellingen / python-zeep / tests / test_wsdl_messages_document.py View on Github external
<input>
            
          
        
      
    
    """.strip()
    )

    root = wsdl.Document(wsdl_content, None)

    binding = root.bindings["{http://tests.python-zeep.org/tns}TestBinding"]
    operation = binding.get("TestOperation")

    serialized = operation.input.serialize(arg1=xsd.AnyObject(xsd.String(), "ah1"))
    expected = """
        
        
          
            
              ah1
            
          
        
    """
    assert_nodes_equal(expected, serialized.content)
    deserialized = operation.input.deserialize(serialized.content)
github mvantellingen / python-zeep / tests / test_xsd_complex_types.py View on Github external
[xsd.Element("item", xsd.AnyType(), min_occurs=1, max_occurs="unbounded")]
        ),
        qname=etree.QName("{http://xml.apache.org/xml-soap}Map"),
    )

    header_Username = KeyValueData(
        xsd.AnyObject(xsd.String(), "Username"),
        value=xsd.AnyObject(xsd.String(), "abc"),
    )
    header_ShopId = KeyValueData(
        xsd.AnyObject(xsd.String(), "ShopId"), value=xsd.AnyObject(xsd.Int(), 123)
    )
    auth = Map(item=[header_Username, header_ShopId])

    header_LimitNum = KeyValueData(
        xsd.AnyObject(xsd.String(), "LimitNum"), value=xsd.AnyObject(xsd.Int(), 2)
    )
    params = Map(item=[header_LimitNum])

    container = schema.get_element("ns0:container")
    obj = container(auth=auth, params=params)

    result = render_node(container, obj)
    expected = load_xml(
        """
    
      
        
          
            Username
            abc
github mvantellingen / python-zeep / tests / test_xsd_any.py View on Github external
"""
        )
    )  # noqa

    container_elm = schema.get_element("{http://tests.python-zeep.org/}container")
    assert container_elm.signature(schema) == (
        "ns0:container(items: {_value_1: ANY}, version: xsd:string, _value_1: ANY[])"
    )

    something = schema.get_element("{http://tests.python-zeep.org/}something")
    foobar = schema.get_element("{http://tests.python-zeep.org/}foobar")

    any_1 = xsd.AnyObject(something, datetime.date(2016, 7, 4))
    any_2 = xsd.AnyObject(foobar, True)
    obj = container_elm(
        items={"_value_1": any_1}, version="str1234", _value_1=[any_1, any_2]
    )

    node = etree.Element("document")
    container_elm.render(node, obj)
    expected = """
        
          
            
              2016-07-04
            
            str1234
            2016-07-04
            true
github mvantellingen / python-zeep / src / zeep / helpers.py View on Github external
qname=etree.QName("{http://xml.apache.org/xml-soap}Map"),
    )

    KeyValueData = xsd.Element(
        "{http://xml.apache.org/xml-soap}KeyValueData",
        xsd.ComplexType(
            xsd.Sequence(
                [xsd.Element("key", xsd.AnyType()), xsd.Element("value", xsd.AnyType())]
            )
        ),
    )

    return Map(
        item=[
            KeyValueData(
                xsd.AnyObject(xsd.String(), key),
                xsd.AnyObject(guess_xsd_type(value), value),
            )
            for key, value in values.items()
        ]