1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/soap_test.py Sun Sep 30 00:55:43 2007 +0000
1.3 @@ -0,0 +1,109 @@
1.4 +#!/usr/bin/env python
1.5 +# -*- coding: iso-8859-15 -*-
1.6 +
1.7 +import libxml2dom.soap
1.8 +
1.9 +request = """<?xml version='1.0' encoding='iso-8859-1'?>
1.10 +<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" >
1.11 + <env:Header>
1.12 + <t:transaction
1.13 + xmlns:t="http://thirdparty.example.org/transaction"
1.14 + env:encodingStyle="http://example.com/encoding"
1.15 + env:mustUnderstand="true" >5</t:transaction>
1.16 + </env:Header>
1.17 + <env:Body>
1.18 + <m:chargeReservation
1.19 + env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
1.20 + xmlns:m="http://travelcompany.example.org/">
1.21 + <m:reservation xmlns:m="http://travelcompany.example.org/reservation">
1.22 + <m:code>FT35ZBQ</m:code>
1.23 + </m:reservation>
1.24 + <o:creditCard xmlns:o="http://mycompany.example.com/financial">
1.25 + <n:name xmlns:n="http://mycompany.example.com/employees">
1.26 + Ĺke Jógvan Řyvind
1.27 + </n:name>
1.28 + <o:number>123456789099999</o:number>
1.29 + <o:expiration>2005-02</o:expiration>
1.30 + </o:creditCard>
1.31 + </m:chargeReservation>
1.32 + </env:Body>
1.33 +</env:Envelope>"""
1.34 +
1.35 +req = libxml2dom.soap.parseString(request)
1.36 +
1.37 +response = """<?xml version='1.0' encoding='iso-8859-1'?>
1.38 +<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" >
1.39 + <env:Header>
1.40 + <t:transaction
1.41 + xmlns:t="http://thirdparty.example.org/transaction"
1.42 + env:encodingStyle="http://example.com/encoding"
1.43 + env:mustUnderstand="true">5</t:transaction>
1.44 + </env:Header>
1.45 + <env:Body>
1.46 + <m:chargeReservationResponse
1.47 + env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
1.48 + xmlns:m="http://travelcompany.example.org/">
1.49 + <m:code>FT35ZBQ</m:code>
1.50 + <m:viewAt>
1.51 + http://travelcompany.example.org/reservations?code=FT35ZBQ
1.52 + </m:viewAt>
1.53 + </m:chargeReservationResponse>
1.54 + </env:Body>
1.55 +</env:Envelope>"""
1.56 +
1.57 +resp = libxml2dom.soap.parseString(response)
1.58 +
1.59 +response2 = """<?xml version='1.0' encoding='iso-8859-1'?>
1.60 +<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" >
1.61 + <env:Header>
1.62 + <t:transaction
1.63 + xmlns:t="http://thirdparty.example.org/transaction"
1.64 + env:encodingStyle="http://example.com/encoding"
1.65 + env:mustUnderstand="true">5</t:transaction>
1.66 + </env:Header>
1.67 + <env:Body>
1.68 + <m:chargeReservationResponse
1.69 + env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
1.70 + xmlns:rpc="http://www.w3.org/2003/05/soap-rpc"
1.71 + xmlns:m="http://travelcompany.example.org/">
1.72 + <rpc:result>m:status</rpc:result>
1.73 + <m:status>confirmed</m:status>
1.74 + <m:code>FT35ZBQ</m:code>
1.75 + <m:viewAt>
1.76 + http://travelcompany.example.org/reservations?code=FT35ZBQ
1.77 + </m:viewAt>
1.78 + </m:chargeReservationResponse>
1.79 + </env:Body>
1.80 +</env:Envelope>"""
1.81 +
1.82 +resp2 = libxml2dom.soap.parseString(response2)
1.83 +
1.84 +failed = """<?xml version='1.0' encoding='iso-8859-1'?>
1.85 +<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
1.86 + xmlns:rpc='http://www.w3.org/2003/05/soap-rpc'>
1.87 + <env:Body>
1.88 + <env:Fault>
1.89 + <env:Code>
1.90 + <env:Value>env:Sender</env:Value>
1.91 + <env:Subcode>
1.92 + <env:Value>rpc:BadArguments</env:Value>
1.93 + </env:Subcode>
1.94 + </env:Code>
1.95 + <env:Reason>
1.96 + <env:Text xml:lang="en-US">Processing error</env:Text>
1.97 + <env:Text xml:lang="cs">Chyba zpracování</env:Text>
1.98 + </env:Reason>
1.99 + <env:Detail>
1.100 + <e:myFaultDetails
1.101 + xmlns:e="http://travelcompany.example.org/faults">
1.102 + <e:message>Name does not match card number</e:message>
1.103 + <e:errorcode>999</e:errorcode>
1.104 + </e:myFaultDetails>
1.105 + </env:Detail>
1.106 + </env:Fault>
1.107 + </env:Body>
1.108 +</env:Envelope>"""
1.109 +
1.110 +f = libxml2dom.soap.parseString(failed)
1.111 +
1.112 +# vim: tabstop=4 expandtab shiftwidth=4
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/tests/xmlrpc_test.py Sun Sep 30 00:55:43 2007 +0000
2.3 @@ -0,0 +1,48 @@
2.4 +#!/usr/bin/env python
2.5 +
2.6 +import libxml2dom.xmlrpc
2.7 +
2.8 +request = """<?xml version="1.0"?>
2.9 +<methodCall>
2.10 + <methodName>examples.getStateName</methodName>
2.11 + <params>
2.12 + <param>
2.13 + <value><i4>41</i4></value>
2.14 + </param>
2.15 + </params>
2.16 + </methodCall>"""
2.17 +
2.18 +req = libxml2dom.xmlrpc.parseString(request)
2.19 +
2.20 +response = """<?xml version="1.0"?>
2.21 +<methodResponse>
2.22 + <params>
2.23 + <param>
2.24 + <value><string>South Dakota</string></value>
2.25 + </param>
2.26 + </params>
2.27 + </methodResponse>"""
2.28 +
2.29 +resp = libxml2dom.xmlrpc.parseString(response)
2.30 +
2.31 +failed = """<?xml version="1.0"?>
2.32 +<methodResponse>
2.33 + <fault>
2.34 + <value>
2.35 + <struct>
2.36 + <member>
2.37 + <name>faultCode</name>
2.38 + <value><int>4</int></value>
2.39 + </member>
2.40 + <member>
2.41 + <name>faultString</name>
2.42 + <value><string>Too many parameters.</string></value>
2.43 + </member>
2.44 + </struct>
2.45 + </value>
2.46 + </fault>
2.47 + </methodResponse>"""
2.48 +
2.49 +f = libxml2dom.xmlrpc.parseString(failed)
2.50 +
2.51 +# vim: tabstop=4 expandtab shiftwidth=4