python client call Java server by xmlrpc

fan.ding1 at kodak.com fan.ding1 at kodak.com
Fri Jan 30 04:15:27 EST 2015


Thanks dieter, The issue is solved.

I use SmartSniff to get the xml message send by java client, and python 
client, find the difference.

Define a new class:
class MyData(object):
    def __init__(self,myKey,myValue):
        self.Key = myKey
        self.Value = myValue

and use this object as parameter, then the server return correct reply.

para = MyData(0.5,0.01)

server.Fun([para ], [ ] )






From:
dieter <dieter at handshake.de>
To:
python-list at python.org
Date:
01/23/2015 03:26 PM
Subject:
Re: python client call Java server by xmlrpc
Sent by:
"Python-list" <python-list-bounces+fan.ding1=kodak.com at python.org>



fan.ding1 at kodak.com writes:

> I have xmlrpc server written in Java, and it has a method like
>
> Fun( vector, vector), the vector is array of user-defined object, which 
is 
> a class  extends HashMap.
>
> And I call it like:
>
> server = xmlrpclib.ServerProxy("http://myserver")
>
> server.Fun( [ {"0.5":0.1}], [ ] )
>
> It always fails with error
>
> 'No method matching arguments: , [Ljava.lang.Object;, 
[Ljava.lang.Object; 
> '
> Does anyone use this before? It troubles me some days.

The standard XML-RPC protocol knows only about a very small set
of types. Extensions are required to pass on more type information.

The (slightly confusing) error message (you got) indicates
that the XML-RPC framework on the server side has
not correctly recognized the types of the incoming parameters:
it should recognize the "[]" (as this is a standard type)
(and maybe the open "[" indicates that it has indeed)
but apparently, it got the content elements only as
generalized "Object"s not something specific (extending "HashMap").


The "xmlrpclib" in the Python runtime libary does not support
extensions to pass on additional type information (as far as I know).
This might indicate that you cannot use Python's "xmlrpclib" out
of the box to interact with your Java implemented XML-RPC service.


I would approach the problem as follows.

Implement a Java based XML-RPC client for your service. Should this
fail, then your service implementation has too complex types for
XML-RPC (and you must simplify them).

Should you succeed, you can use a tcp logger (or maybe debugging
tools of the Java libary implementing XML-RPC) to determine
the exact messages exchanged between client and server.
This way, you can learn how your Java libraries pass on non standard
type information. You can then derive a new class from Python's 
"xmlrpclib"
and implement there this type information passing extension (apparently
used by your Java libaries).

-- 
https://mail.python.org/mailman/listinfo/python-list


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150130/cea7fc61/attachment.html>


More information about the Python-list mailing list