Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
<input>
""".strip()
)
root = wsdl.Document(wsdl_content, None)
binding = root.bindings["{http://tests.python-zeep.org/tns}TestBinding"]
operation = binding.get("TestOperation")
header = xsd.Element(
"{http://test.python-zeep.org/custom}auth",
xsd.ComplexType(
[xsd.Element("{http://test.python-zeep.org/custom}username", xsd.String())]
),
)
serialized = operation.input.serialize(
arg1="ah1", arg2="ah2", _soapheaders=[header(username="mvantellingen")]
)
expected = """
<input>
<output>
</output>
""".strip()
)
root = wsdl.Document(wsdl_content, None)
binding = root.bindings["{http://tests.python-zeep.org/tns}TestBinding"]
operation = binding.get("TestOperation")
response_body = load_xml(
"""
"""
)
<input>
<output>
</output>
""".strip()
)
root = wsdl.Document(wsdl_content, None)
binding = root.bindings["{http://tests.python-zeep.org/tns}TestBinding"]
operation = binding.get("TestOperation")
response_body = load_xml(
"""
ah1
ah2
<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
<input>
<output>
</output>
""".strip()
)
root = wsdl.Document(wsdl_content, None)
binding = root.bindings["{http://tests.python-zeep.org/tns}TestBinding"]
operation = binding.get("TestOperation")
response_body = load_xml(
"""
mvantellingen
<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(
request1={"arg1": "ah1", "arg2": "ah2"}, request2={"arg1": "ah1", "arg2": "ah2"}
)
expected = """
ah1
ah2
""".strip()
)
root = wsdl.Document(wsdl_content, None)
binding = root.bindings["{http://tests.python-zeep.org/}Binding"]
operation = binding.get("getResult")
assert operation.input.signature() == ""
serialized = operation.input.serialize()
expected = """
"""
assert_nodes_equal(expected, serialized.content)
<input>
""".strip()
)
root = wsdl.Document(wsdl_content, None)
binding = root.bindings["{http://tests.python-zeep.org/tns}TestBinding"]
operation = binding.get("TestOperation")
header = xsd.ComplexType(
xsd.Sequence(
[
xsd.Element(
"{http://www.w3.org/2005/08/addressing}Action", xsd.String()
),
xsd.Element("{http://www.w3.org/2005/08/addressing}To", xsd.String()),
]
)
)
header_value = header(Action="doehet", To="server")
serialized = operation.input.serialize(
<input>
""".strip()
)
root = wsdl.Document(wsdl_content, None)
binding = root.bindings["{http://tests.python-zeep.org/tns}TestBinding"]
operation = binding.get("TestOperation")
header_value = etree.Element("{http://test.python-zeep.org/custom}auth")
etree.SubElement(
header_value, "{http://test.python-zeep.org/custom}username"
).text = "mvantellingen"
serialized = operation.input.serialize(
arg1="ah1", arg2="ah2", _soapheaders=[header_value]
)
expected = """
<input>
<output>
</output>
"""
)
# parse the content
root = wsdl.Document(wsdl_content, None)
binding = root.bindings["{http://tests.python-zeep.org/tns}TestBinding"]
operation = binding.get("TestOperation")
# General assertions on the input
assert (
operation.input.body.signature(schema=root.types) == "ns0:Request(xsd:string)"
)
assert operation.input.header.signature(schema=root.types) == "soap-env:Header()"
assert (
operation.input.envelope.signature(schema=root.types)
== "soap-env:envelope(body: xsd:string)"
)
assert operation.input.signature(as_output=False) == "xsd:string"