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.

def serialize(self, pyobj, typecode=None, root=None, header_pyobjs=(), **kw):
        '''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.
        '''
        self.body = None
        if self.envelope: 
            soap_env = _reserved_ns['SOAP-ENV']
            self.dom.createDocument(soap_env, 'Envelope')
            for prefix, nsuri in _reserved_ns.items():
                self.dom.setNamespaceAttribute(prefix, nsuri)
            self.writeNSdict(self.nsdict)
            if self.encodingStyle:
                self.dom.setAttributeNS(soap_env, 'encodingStyle', 
                                        self.encodingStyle)
            if self.header:
                self._header = self.dom.createAppendElement(soap_env, 'Header')

                for h in header_pyobjs:
                    self.serialize_header(h, **kw)

            self.body = self.dom.createAppendElement(soap_env, 'Body')
        else:
            self.dom.createDocument(None,None)

        if typecode is None: 
            typecode = pyobj.__class__.typecode
            
        if self.body is None:
            elt = typecode.serialize(self.dom, self, pyobj, **kw)
        else:
            elt = typecode.serialize(self.body, self, pyobj, **kw)
            
        if root is not None:
            if root not in [ 0, 1 ]:
                raise ValueError, "SOAP-ENC root attribute not in [0,1]"
            elt.setAttributeNS(SOAP.ENC, 'root', root)
                        
        return self