当前位置: 首页>>代码示例>>Python>>正文


Python SoapWriter.serialize方法代码示例

本文整理汇总了Python中ZSI.writer.SoapWriter.serialize方法的典型用法代码示例。如果您正苦于以下问题:Python SoapWriter.serialize方法的具体用法?Python SoapWriter.serialize怎么用?Python SoapWriter.serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZSI.writer.SoapWriter的用法示例。


在下文中一共展示了SoapWriter.serialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_local_attribute1

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
    def test_local_attribute1(self):
        """
        """
        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)
开发者ID:mikedougherty,项目名称:ZSI,代码行数:29,代码来源:test_SubstitutionGroup.py

示例2: test_local_choice_default_facets_legal1

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
 def test_local_choice_default_facets_legal1(self):
     """<choice minOccurs=1 maxOccurs=1>
     """
     pyobj = GED("urn:example", "Easy").pyclass()
     pyobj.Rank = 1
     sw = SoapWriter()
     sw.serialize(pyobj)
     print str(sw)
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:10,代码来源:test_Choice.py

示例3: test_local_choice_maxOccurs_unbounded

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
 def test_local_choice_maxOccurs_unbounded(self):
     """<choice minOccurs=1 maxOccurs=unbounded>
     """
     pyobj = GED("urn:example", "Hard").pyclass()
     pyobj.Name = ["steve", "mark"]
     pyobj.Any = ["whatever"]
     pyobj.Rank = [2,3,4]
     sw = SoapWriter()
     sw.serialize(pyobj)
     print str(sw)
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:12,代码来源:test_Choice.py

示例4: test_local_type_substitution2

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
    def test_local_type_substitution2(self):
        """test extension of extension"""

        attr1 = 'aone'
        attr2 = 'atwo'
        attr3 = 'athree'
        self.types_module
        pyobj = GED('urn:test', 'test').pyclass()

        # [ 1489129 ] Unexpected subsitution error message
        #  try to parse before type ever initialized
        """
        ps = ParsedSoap(MSG1)
        pyobj0 = ps.Parse(pyobj.typecode)
        sub0 = pyobj0.Actor
        self.failUnless(sub0.get_attribute_attr1() == attr1, 'bad attribute1')
        self.failUnless(sub0.get_attribute_attr2() == attr2, 'bad attribute2')
        """

        # [ 1489090 ] Derived type attributes don't populate the attr dictionary
        # [ 1489677 ] Derivation from derived type missing derived element
        # 
        pyobj.Actor = sub1 = GTD('urn:test', 'TopActor')(None).pyclass()
        sub1.Element1 = 'one'
        sub1.Element2 = 'two'
        sub1.Element3 = 'three'
        sub1.set_attribute_attr1(attr1)
        sub1.set_attribute_attr2(attr2)
        sub1.set_attribute_attr3(attr3)
        
        sw = SoapWriter()
        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 1')
        self.failUnless(sub2.get_attribute_attr2() == attr2, 'bad attribute 2')
        self.failUnless(sub2.get_attribute_attr3() == attr3, 'bad attribute 3')

        self.failUnless(sub2.Element1 == sub1.Element1, 'bad element 1')
        self.failUnless(sub2.Element2 == sub1.Element2, 'bad element 2')
        self.failUnless(sub2.Element3 == sub1.Element3, 'bad element 3')
                
        # 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)
开发者ID:360ed,项目名称:ZSI,代码行数:57,代码来源:test_DerivedTypes.py

示例5: test_local_choice_maxOccurs_unbounded

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
 def test_local_choice_maxOccurs_unbounded(self):
     """<choice minOccurs=1 maxOccurs=unbounded>
     """
     pyobj = GED("urn:example", "Hard").pyclass()
     pyobj.Name = "steve"
     pyobj.Name.append("mark")
     pyobj.Any = "whatever"
     pyobj.Rank = 2
     pyobj.Rank.append(3)
     pyobj.Rank.append(4)
     sw = SoapWriter()
     sw.serialize(pyobj)
     print(str(sw))
开发者ID:istobran,项目名称:python-ZSI-py3,代码行数:15,代码来源:test_Choice.py

示例6: processRequest

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
    def processRequest(cls, obj, nsdict={}, header=True,
                       **kw):
        tc = None
        if kw.has_key('requesttypecode'):
            tc = kw['requesttypecode']
        elif kw.has_key('requestclass'):
            tc = kw['requestclass'].typecode
        else:
            tc = getattr(obj.__class__, 'typecode', None)

        sw = SoapWriter(nsdict=nsdict, header=header,
                        outputclass=cls.writerClass)
        sw.serialize(obj, tc)
        return sw
开发者ID:mikedougherty,项目名称:ZSI,代码行数:16,代码来源:client.py

示例7: test_local_empty_attribute

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
    def test_local_empty_attribute(self):
        # [ 1452752 ] attribute with empty value doesn't appear in parsed object
        myString = ""
        pyobj = GED("urn:example", "Test1").pyclass()
        pyobj.set_attribute_myString(myString)

        sw = SoapWriter()
        sw.serialize(pyobj)
        soap = str(sw)

        print soap
        ps = ParsedSoap(soap)
        pyobj2 = ps.Parse(pyobj.typecode)

        test = pyobj2.get_attribute_myString()
        self.failUnlessEqual(myString, str(test))
开发者ID:mikedougherty,项目名称:ZSI,代码行数:18,代码来源:test_Attributes.py

示例8: _test_local_serialize1

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
def _test_local_serialize1():
        """
      <element name="GlobalElementLocalType">
          <complexType>
            <sequence>
              <element name="Unqualified1">
                  <complexType/>
              </element>
              <element name="Unqualified2" type="xsd:int"/>
              <element name="Unqualified3" type="tns:GlobalType"/>

              <element name="Unqualified4">
                  <simpleType>
                       <restriction base="xsd:string"/>
                  </simpleType>
              </element>

            </sequence>
          </complexType>
      </element>
        """
        tns = "urn:test"
        pyobj = GED(tns, "GlobalElementLocalType").pyclass()
        pyobj.Unqualified1 = pyobj.new_Unqualified1()
        pyobj.Unqualified2 = 2

        pyobj.Unqualified3 = pyobj.new_Unqualified3()
        pyobj.Unqualified3.Unqualified1 = pyobj.Unqualified3.new_Unqualified1()
        pyobj.Unqualified3.Unqualified2 = 32

        pyobj.Unqualified4 = "whatever"

        sw = SoapWriter(envelope=False)
        sw.serialize(pyobj)
        xml = str(sw)
        print xml

        et = ElementTree.fromstring(xml)

        # GlobalElementLocalType
        assert(et.tag == '{urn:test}GlobalElementLocalType'), "root GED"

        for i,j in zip([ 'Unqualified1', 'Unqualified2', 'Unqualified3', 'Unqualified4'],
            map(lambda c: c.tag, et.getchildren())):

            assert(i == j), 'Match Failed: expected "%s" not "%s"' %(i,j)
开发者ID:mikedougherty,项目名称:ZSI,代码行数:48,代码来源:test_Unqualified.py

示例9: test_local_type_substitution_test2

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
    def test_local_type_substitution_test2(self):
        """test extension of extension"""

        attr1 = 'aone'
        attr2 = 'atwo'
        attr3 = 'athree'
        self.types_module
        pyobj = GED('urn:test', 'test2').pyclass()

        # Test maxOccurs>1 for substitution 
        # 
        pyobj.Actor = [GTD('urn:test', 'TopActor')(None).pyclass()]
        sub1 = pyobj.Actor[0]
        sub1.Element1 = 'one'
        sub1.Element2 = 'two'
        sub1.Element3 = 'three'
        sub1.set_attribute_attr1(attr1)
        sub1.set_attribute_attr2(attr2)
        sub1.set_attribute_attr3(attr3)
        
        sw = SoapWriter()
        sw.serialize(pyobj)
        xml = str(sw)
        ps = ParsedSoap(xml)
        pyobj2 = ps.Parse(pyobj.typecode)
        sub2 = pyobj2.Actor[0]

        self.failUnless(sub2.get_attribute_attr1() == attr1, 'bad attribute 1')
        self.failUnless(sub2.get_attribute_attr2() == attr2, 'bad attribute 2')
        self.failUnless(sub2.get_attribute_attr3() == attr3, 'bad attribute 3')

        self.failUnless(sub2.Element1 == sub1.Element1, 'bad element 1')
        self.failUnless(sub2.Element2 == sub1.Element2, 'bad element 2')
        self.failUnless(sub2.Element3 == sub1.Element3, 'bad element 3')
                
        # 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)
开发者ID:360ed,项目名称:ZSI,代码行数:47,代码来源:test_DerivedTypes.py

示例10: test_local_type_substitution1

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
    def test_local_type_substitution1(self):
        """test extension.   Parse known instance, serialize an equivalent, Parse it back. """
        attr1 = 'myclass'
        attr2 = 'whatever'
        self.types_module
        pyobj = GED('urn:test', 'test').pyclass()

        # [ 1489129 ] Unexpected subsitution error message
        #  try to parse before type ever initialized
        ps = ParsedSoap(MSG1)
        pyobj0 = ps.Parse(pyobj.typecode)
        sub0 = pyobj0.Actor
        self.failUnless(sub0.get_attribute_attr1() == attr1, 'bad attribute1')
        self.failUnless(sub0.get_attribute_attr2() == attr2, 'bad attribute2')

        # [ 1489090 ] Derived type attributes don't populate the attr dictionary
        # 
        pyobj.Actor = sub1 = GTD('urn:test', 'MiddleActor')(None).pyclass()
        sub1.Element1 = 'foo'
        sub1.Element2 = 'bar'
        sub1.set_attribute_attr1(attr1)
        sub1.set_attribute_attr2(attr2)
        
        sw = SoapWriter()
        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)
开发者ID:360ed,项目名称:ZSI,代码行数:45,代码来源:test_DerivedTypes.py

示例11: check_list_defs

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
    def check_list_defs(self):
        gl = globals()
        for klass in map(lambda h: gl[h], filter(lambda g: (g.startswith('TestList') and 
            issubclass(gl[g],ZSI.TC.List)), gl)):

            typecode = klass('whatever', nillable=True)
            data = None
            for i in range(10):
                sw = SoapWriter()
                sw.serialize(data, typecode)
                s = str(sw)
                #print s
                ps = ParsedSoap(s); pyobj = ps.Parse(typecode)
                assert pyobj == data, 'Data corruption expected "%s", got "%s"' %(str(data),str(pyobj))
                if data is None: 
                    data = []; continue;

                # 
                # cut last 3 fields off: weekday (0-6, Monday is 0), Julian day (day in the year, 1-366),
                # DST (Daylight Savings Time) flag (-1, 0 or 1)
                # 
                utc = list(time.gmtime(i)[:-3]) + [999,0,0] 
                data.append(tuple(utc))
开发者ID:acigna,项目名称:pywez,代码行数:25,代码来源:test_list.py

示例12: processResponse

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
 def processResponse(cls, output, **kw):
     sw = SoapWriter(outputclass=cls.writerClass)
     sw.serialize(output)
     return sw
开发者ID:joshhanna,项目名称:apollo,代码行数:6,代码来源:WSresource.py

示例13: test_local_attribute1

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
    def test_local_attribute1(self):
        """
        """
        myDouble = 4.5
        myInt = 9
        myFloat = 3.0001
        myDecimal = 8.999
        myGDateTime = time.gmtime()
        myAnyURI = "urn:whatever"
        myQName = ("urn:test", "qbert")
        myString = "whatever"
        myHexBinary = hex(888)

        pyobj = GED("urn:example", "Test1").pyclass()
        # Test serialize/parse
        pyobj.set_attribute_myDecimal(myDecimal)
        pyobj.set_attribute_myDouble(myDouble)
        pyobj.set_attribute_myFloat(myFloat)
        pyobj.set_attribute_myInt(myInt)
        pyobj.set_attribute_myDateTime(myGDateTime)

        pyobj.set_attribute_myGDay(myGDateTime)
        pyobj.set_attribute_myGMonth(myGDateTime)
        pyobj.set_attribute_myGYear(myGDateTime)
        pyobj.set_attribute_myGYearMonth(myGDateTime)
        pyobj.set_attribute_myDate(myGDateTime)
        pyobj.set_attribute_myTime(myGDateTime)

        pyobj.set_attribute_myAnyURI(myAnyURI)
        pyobj.set_attribute_myString(myString)
        pyobj.set_attribute_myHexBinary(myHexBinary)
        pyobj.set_attribute_myDuration(myGDateTime)

        # Problems parsings
        pyobj.set_attribute_myQName(myQName)
        pyobj.set_attribute_myGMonthDay(myGDateTime)


        #TODO:
        #pyobj.set_attribute_myBase64Binary("")
        #pyobj.set_attribute_myNOTATION("NOT")

        sw = SoapWriter()
        sw.serialize(pyobj)
        soap = str(sw)

        ps = ParsedSoap(soap)
        pyobj2 = ps.Parse(pyobj.typecode)

        test = pyobj2.get_attribute_myInt()
        self.failUnlessEqual(myInt, test)

        test = pyobj2.get_attribute_myDouble()
        self.failUnlessEqual(myDouble, test)

        test = pyobj2.get_attribute_myFloat()
        self.failUnlessEqual(myFloat, test)

        test = pyobj2.get_attribute_myDecimal()
        self.failUnlessEqual(myDecimal, test)

        test = pyobj2.get_attribute_myAnyURI()
        self.failUnlessEqual(myAnyURI, test)

        test = pyobj2.get_attribute_myQName()
        self.failUnlessEqual(myQName, test)

        test = pyobj2.get_attribute_myString()
        self.failUnlessEqual(myString, test)

        test = pyobj2.get_attribute_myHexBinary()
        self.failUnlessEqual(myHexBinary, test)

        # DateTime stuff
        test = pyobj2.get_attribute_myDateTime()
        self.failUnlessEqual(myGDateTime[:-3], test[:-3])

        test = pyobj2.get_attribute_myDate()
        self.failUnlessEqual(myGDateTime[:3], test[:3])

        test = pyobj2.get_attribute_myTime()
        self.failUnlessEqual(myGDateTime[4:5], test[4:5])

        test = pyobj.get_attribute_myDuration()
        self.failUnlessEqual(myGDateTime, test)

        # Bug [ 1453421 ] Incorrect format for type gDay
        test = pyobj2.get_attribute_myGDay()
        self.failUnlessEqual(myGDateTime[2], test[2])

        test = pyobj2.get_attribute_myGMonth()
        self.failUnlessEqual(myGDateTime[1], test[1])

        test = pyobj2.get_attribute_myGYear()
        self.failUnlessEqual(myGDateTime[0], test[0])

        test = pyobj2.get_attribute_myGYearMonth()
        self.failUnlessEqual(myGDateTime[:2], test[:2])
开发者ID:mikedougherty,项目名称:ZSI,代码行数:100,代码来源:test_Attributes.py

示例14: method

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
            request,result = method(ps, address)
        else: 
            request,result = method(ps)
    except Exception, e:
        return SendFault(FaultFromException(e, 0, sys.exc_info()[2]), **kw)

    # Verify if Signed
    service.verify(ps)

    # If No response just return.
    if result is None:
        return SendResponse('', **kw)

    sw = SoapWriter(nsdict=nsdict)
    try:
        sw.serialize(result)
    except Exception, e:
        return SendFault(FaultFromException(e, 0, sys.exc_info()[2]), **kw)

    if isWSResource is True:
        action = service.getResponseAction(ps, action)
        addressRsp = Address(action=action)
        try:
            addressRsp.setResponseFromWSAddress(address, localURL)
            addressRsp.serialize(sw)
        except Exception, e:
            return SendFault(FaultFromException(e, 0, sys.exc_info()[2]), **kw)

    # Create Signatures
    service.sign(sw)
开发者ID:japina,项目名称:ZSI-hacking,代码行数:32,代码来源:ServiceContainer.py

示例15: test_local_EchoBoolean

# 需要导入模块: from ZSI.writer import SoapWriter [as 别名]
# 或者: from ZSI.writer.SoapWriter import serialize [as 别名]
 def test_local_EchoBoolean(self):
     from ZSI.writer import SoapWriter
     msg = self.client_module.echoBooleanRequest()
     msg._inputBoolean = True
     sw = SoapWriter()
     sw.serialize(msg)
开发者ID:mikedougherty,项目名称:ZSI,代码行数:8,代码来源:test_WhiteMesa.py


注:本文中的ZSI.writer.SoapWriter.serialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。