Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fwd: Request for Information XML-RPC (Python)

21 views
Skip to first unread message

Davide D'Arenzo

unread,
Jul 29, 2015, 8:59:39 AM7/29/15
to pytho...@python.org

Goodmorning dear Team,

I'm Davide D'Arenzo and I'm working with Python using the standard xmlrpclib library communicating between a JavaServer (that host xmlrpc server) and my python client. I have a problem and I hope that you should solve my issue.

I want to send a DOM instance through xmlrpc protocol. I know that the istance are impossible to manage by xmlrpclib library in Python but this is what I need. I'm trying to understand why is not possible to marshal the class Nodelist and I recognize that the target function is dumps(self, values) in class Marshaller because she couldn't find this type of Python Object.

For Instance, the Fault code is this:

Traceback (most recent call last):
  File "testRestSwi.py", line 31, in <module>
    conn.xxx.xxx(dom3,"xxx","xxx")
  File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1572, in __request
    allow_none=self.__allow_none)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1085, in dumps
    data = m.dumps(params)
  File "/usr/lib/python2.7/xmlrpclib.py", line 632, in dumps
    dump(v, write)
  File "/usr/lib/python2.7/xmlrpclib.py", line 654, in __dump
    f(self, value, write)
  File "/usr/lib/python2.7/xmlrpclib.py", line 756, in dump_instance
    self.dump_struct(value.__dict__, write)
  File "/usr/lib/python2.7/xmlrpclib.py", line 735, in dump_struct
    dump(v, write)
  File "/usr/lib/python2.7/xmlrpclib.py", line 646, in __dump
    raise TypeError, "cannot marshal %s objects" % type(value)
TypeError: cannot marshal <class 'xml.dom.minicompat.NodeList'> objects

Now, I would want to solve this problem and for sure there are many solutions. But I don't know how to develop or implement something within the xmlrpclib in order to avoid the "marshalling" problem. Keep in mind that the file object must be a DOM, is aim, uncheangeable.

For Instance, I'm developing the following:
import xml.dom.minidom as parser
import xmlrpclib
dom3 = parser.parseString("xxx")
conn = xmlrpclib.ServerProxy('xxx',allow_none=True,verbose=True)
conn.xxx.xxx(dom3,"xxx","xxx") #<--- The problem Here.

Might you help me?
Thank you a lot.

Irmen de Jong

unread,
Jul 29, 2015, 4:13:17 PM7/29/15
to
On 29-7-2015 14:52, Davide D'Arenzo wrote:

> I want to send a DOM instance through xmlrpc protocol. I know that the istance are
> impossible to manage by xmlrpclib library in Python but this is what I need. I'm trying
> to understand why is not possible to marshal the class Nodelist and I recognize that the
> target function is dumps(self, values) in class Marshaller because she couldn't find
> this type of Python Object.

One serialized form of a DOM is.... an XML document. So why not just send the XML
document itself?

Just ask the dom for its string/xml form and send that as a string across your xml-rpc call.

Irmen

dieter

unread,
Jul 30, 2015, 2:11:10 AM7/30/15
to pytho...@python.org
"Davide D'Arenzo" <davide....@gmail.com> writes:

> I'm Davide D'Arenzo and I'm working with Python using the standard
> xmlrpclib library communicating between a JavaServer (that host xmlrpc
> server) and my python client. I have a problem and I hope that you should
> solve my issue.
>
> I want to send a DOM instance through xmlrpc protocol. I know that the
> istance are impossible to manage by xmlrpclib library in Python but this is
> what I need.

XML-RPC supports only a very small set of elementary types - and
"DOM instance" does not belong to this set.

Thus, you must ask your server administrator as what type the server
expects to get the XML (this may either by "string" or "binary"; I suppose,
it will be "binary"). You then convert your DOM instance into an
XML document, potentially using an appropriate encoding (likely "utf-8"),
and potentially wrap it into "xmlrpclib"'s "binary" wrapper (in case,
the server expects a binary string).


0 new messages