def serialize(self, pyobj, typecode=None, root=None, header_pyobjs=(), **kw):
self.body = None<EOL>if self.envelope: <EOL><INDENT>soap_env = _reserved_ns['<STR_LIT>']<EOL>self.dom.createDocument(soap_env, '<STR_LIT>')<EOL>for prefix, nsuri in list(_reserved_ns.items()):<EOL><INDENT>self.dom.setNamespaceAttribute(prefix, nsuri)<EOL><DEDENT>self.writeNSdict(self.nsdict)<EOL>if self.encodingStyle:<EOL><INDENT>self.dom.setAttributeNS(soap_env, '<STR_LIT>', <EOL>self.encodingStyle)<EOL><DEDENT>if self.header:<EOL><INDENT>self._header = self.dom.createAppendElement(soap_env, '<STR_LIT>')<EOL>for h in header_pyobjs:<EOL><INDENT>self.serialize_header(h, **kw)<EOL><DEDENT><DEDENT>self.body = self.dom.createAppendElement(soap_env, '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>self.dom.createDocument(None,None)<EOL><DEDENT>if typecode is None: <EOL><INDENT>typecode = pyobj.__class__.typecode<EOL><DEDENT>if self.body is None:<EOL><INDENT>elt = typecode.serialize(self.dom, self, pyobj, **kw)<EOL><DEDENT>else:<EOL><INDENT>elt = typecode.serialize(self.body, self, pyobj, **kw)<EOL><DEDENT>if root is not None:<EOL><INDENT>if root not in [ <NUM_LIT:0>, <NUM_LIT:1> ]:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>elt.setAttributeNS(SOAP.ENC, '<STR_LIT:root>', root)<EOL><DEDENT>return self<EOL>
Serialize a Python object to the output stream.
           pyobj -- python instance to serialize in body.
           typecode -- typecode describing body 
           root -- SOAP-ENC:root
           header_pyobjs -- list of pyobj for soap header inclusion, each
              instance must specify the typecode attribute.