예제 #1
0
        sw.serialize(pyobj)
        xml = str(sw)
        ps = ParsedSoap(xml)
        pyobj2 = ps.Parse(pyobj.typecode)
        sub2 = pyobj2.Actor

        self.failUnless(sub2.get_attribute_attr1() == attr1,
                        'bad attribute class')
        self.failUnless(sub2.get_attribute_attr2() == attr2,
                        'bad attribute name')

        # check parsed out correct type
        self.failUnless(
            isinstance(sub2.typecode, sub1.typecode.__class__),
            'local element actor "%s" must be an instance of "%s"' %
            (sub2.typecode, sub1.typecode.__class__))

        # check local element is derived from base
        base = GTD('urn:test', 'BaseActor')
        self.failUnless(
            isinstance(sub2.typecode, base),
            'local element actor must be a derived type of "%s"' % base)


MSG1 = """<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body xmlns:ns1="urn:test"><ns1:test><actor attr1="myclass" attr2="whatever" xsi:type="ns1:MiddleActor"><element1 xsi:type="xsd:string">foo</element1><element2 xsi:type="xsd:string">bar</element2></actor></ns1:test></SOAP-ENV:Body></SOAP-ENV:Envelope>"""

NO_SUB_MSG = """<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body xmlns:ns1="urn:test"><ns1:test><actor attr1="myclass" attr2="whatever" xsi:type="ns1:Bogus"><element1 xsi:type="xsd:string">foo</element1><element2 xsi:type="xsd:string">bar</element2></actor></ns1:test></SOAP-ENV:Body></SOAP-ENV:Envelope>"""

if __name__ == "__main__":
    main()
예제 #2
0
        self.types_module

        xml = """<?xml version="1.0" encoding="UTF-8"?>
        <holder xmlns='urn:subGroup:types'>
        <baseElt><base>from base</base></baseElt>
        <childElt><base>from base</base><child>from child</child></childElt></holder>"""

        ps = ParsedSoap(xml, envelope=False)
        p1 = ps.Parse(GED("urn:subGroup:types", "holder"))

        b1 = p1.BaseElt[0]
        c1 = p1.BaseElt[1]

        sw = SoapWriter(envelope=False)
        sw.serialize(p1)

        ps = ParsedSoap(str(sw), envelope=False)
        p2 = ps.Parse(GED("urn:subGroup:types", "holder"))
        b2 = p2.BaseElt[0]
        c2 = p2.BaseElt[1]

        self.failUnlessEqual(b1.Base, b2.Base)
        self.failUnlessEqual(c1.Base, c2.Base)
        self.failUnlessEqual(c1.Child, c2.Child)



if __name__ == "__main__" :
    main()