def test_rpc_message_deserializer(abstract_message_output): response_body = load_xml(""" <SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <mns:Response xmlns:mns="http://test.python-zeep.org/tests/rpc" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <result xsi:type="xsd:string">foobar</result> </mns:Response> </SOAP-ENV:Body> """) # noqa wsdl = stub(schema=stub(_prefix_map={})) operation = stub(soapaction='my-action', name='something') msg = messages.RpcMessage( wsdl=wsdl, name=None, operation=operation, nsmap=soap.Soap11Binding.nsmap, type='output') msg._info = { 'body': {'namespace': 'http://test.python-zeep.org/tests/rpc'}, 'header': None, 'headerfault': None } msg.resolve(wsdl, abstract_message_output) result = msg.deserialize(response_body) assert result == 'foobar'
def test_rpc_message_serializer(abstract_message_input): wsdl = stub(schema=stub(_prefix_map={})) operation = stub(soapaction='my-action', name='Operation') msg = messages.RpcMessage( wsdl=wsdl, name=None, operation=operation, nsmap=soap.Soap11Binding.nsmap, type='input') msg._info = { 'body': { 'namespace': 'http://test.python-zeep.org/tests/rpc', }, 'header': None, 'headerfault': None } msg.resolve(wsdl, abstract_message_input) serialized = msg.serialize(arg1='ah1', arg2='ah2') expected = """ <?xml version="1.0"?> <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> <soap-env:Body> <ns0:Operation xmlns:ns0="http://test.python-zeep.org/tests/rpc"> <arg1>ah1</arg1> <arg2>ah2</arg2> </ns0:Operation> </soap-env:Body> </soap-env:Envelope> """ assert_nodes_equal(expected, serialized.content)
def test_rpc_message_signature_output(abstract_message_output): wsdl = stub(schema=stub(_prefix_map={})) operation = stub(soapaction='my-action') msg = messages.RpcMessage( wsdl=wsdl, name=None, operation=operation, nsmap=soap.Soap11Binding.nsmap, type='output') msg._info = { 'body': {'namespace': 'http://test.python-zeep.org/tests/rpc'}, 'header': None, 'headerfault': None } msg.resolve(wsdl, abstract_message_output) assert msg.signature(True) == 'xsd:string'