You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rpc-dev@xml.apache.org by mike marsh <sa...@yahoo.com> on 2002/09/20 18:25:18 UTC

need help: cannot marshal

I learned about XMLRPC only a few days ago, so if it
sounds like I don't know what I'm talking about
then...I don't.

I've read that the XMLRPC spec only supports a few
data types, and I think I need to modify my
XmlRpcClient to support additional data types.

MY SITUATION:
I need to connect to a Zope database via XmlRpc. 
Someone else maintains the xmlrpc methods and code on
the Zope server.  I try calling a particular method,
but an XmlRpcException gets thrown.  The exception
string says "cannot marshal <type 'long int'>".  I
suppose I need an XmlRpc parser that can interpret
<long int> and create a Long object.  Can someone tell
me how to modifiy org.apache.xml.XmlRpc.java?

Below is some more info that may help explain my
problem.

Thanks in advance,
mike

STACK TRACE:
org.apache.xmlrpc.XmlRpcException: Unexpected Zope
exception: cannot marshal <type 'long int'> objects
        at
org.apache.xmlrpc.XmlRpcClient$Worker.execute(XmlRpcClient.java:414)
        at
org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:149)
        at
ncmi.dbclient.DBClient.query(DBClient.java:42)
        at ncmi.dbclient.Browser.main(Browser.java:91)


DEBUG:
Client calling procedure
'EMDB.Groups.Group_1.Project_59.Microscopy.values'
with parameters []
Beginning parsing XML input stream
startElement: methodResponse
startElement: value
startElement: struct
startElement: member
startElement: name
endElement: name
startElement: value
startElement: int
endElement: int
endElement: value
endElement: member
startElement: member
startElement: name
endElement: name
startElement: value
startElement: string
endElement: string
endElement: value
endElement: member
endElement: struct
endElement: value
endElement: fault
endElement: methodResponse


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

Re: need help: cannot marshal

Posted by Tim Peierls <ti...@peierls.net>.
mike marsh wrote:
> Thanks!  I made the additions you suggested.

You're welcome. But read on:


> Not working yet, but soon.  When I get it resolved, I'll post.

This is definitely _not_ something to consider adding to the
Apache codebase. Your Zope friends are providing a service that 
is not talking XML-RPC. You should make that clear to them, and 
urge them to change it so that it does, or at least not to make 
any claims that it does.

Adding this kind of flexibility to the Java XML-RPC code, even
optionally, encourages ad hoc deviation from the XML-RPC spec,
which is exactly why Dave Winer has been so adamant about 
sticking to the clunky spec that we have.

So your changes are one-off changes, not to be adopted generally.

--tim


Re: need help: cannot marshal

Posted by Tim Peierls <ti...@peierls.net>.
mike marsh wrote:
> Thanks!  I made the additions you suggested.

You're welcome. But read on:


> Not working yet, but soon.  When I get it resolved, I'll post.

This is definitely _not_ something to consider adding to the
Apache codebase. Your Zope friends are providing a service that 
is not talking XML-RPC. You should make that clear to them, and 
urge them to change it so that it does, or at least not to make 
any claims that it does.

Adding this kind of flexibility to the Java XML-RPC code, even
optionally, encourages ad hoc deviation from the XML-RPC spec,
which is exactly why Dave Winer has been so adamant about 
sticking to the clunky spec that we have.

So your changes are one-off changes, not to be adopted generally.

--tim


Re: need help: cannot marshal

Posted by mike marsh <sa...@yahoo.com>.
Thanks!  I made the additions you suggested.  Not
working yet, but soon.  When I get it resolved, I'll
post.

thanks again,
mike

--- Tim Peierls <ti...@peierls.net> wrote:
> mike marsh wrote:
> > Unfortunately, the other folks around me are
> python gurus. ...
> > Zope and database browser1 both use the same
> python module for 
> > xmlrpc, which obviously deviates from the xmlrpc
> standard.  
> 
> Deviant Python programmers, I figured it might be
> something like 
> that. Just don't tell Dave Winer I told you any of
> this. :-)
> 
> XmlRpc.java, line 445, method startElement is the
> one that does the 
> parsing, line 601, method characterData does the
> mapping. You would 
> need to define another type constant, LONG, near
> line 145.
> 
> Going the other direction, XmlWriter.java, line 155,
> method writeObject
> is the one that maps parameter values to XML
> elements.
> 
> These line numbers refer to the latest CVS snapshot.
> 
> One thing: <long int> isn't even valid XML, so make
> sure you know
> exactly what tag the Python piece is expecting,
> probably something
> like <long>345</long>, <long-int>345</long-int>, or
> <long_int>345</long_int>.
> 
> --tim
> 


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

Re: need help: cannot marshal

Posted by mike marsh <sa...@yahoo.com>.
Thanks!  I made the additions you suggested.  Not
working yet, but soon.  When I get it resolved, I'll
post.

thanks again,
mike

--- Tim Peierls <ti...@peierls.net> wrote:
> mike marsh wrote:
> > Unfortunately, the other folks around me are
> python gurus. ...
> > Zope and database browser1 both use the same
> python module for 
> > xmlrpc, which obviously deviates from the xmlrpc
> standard.  
> 
> Deviant Python programmers, I figured it might be
> something like 
> that. Just don't tell Dave Winer I told you any of
> this. :-)
> 
> XmlRpc.java, line 445, method startElement is the
> one that does the 
> parsing, line 601, method characterData does the
> mapping. You would 
> need to define another type constant, LONG, near
> line 145.
> 
> Going the other direction, XmlWriter.java, line 155,
> method writeObject
> is the one that maps parameter values to XML
> elements.
> 
> These line numbers refer to the latest CVS snapshot.
> 
> One thing: <long int> isn't even valid XML, so make
> sure you know
> exactly what tag the Python piece is expecting,
> probably something
> like <long>345</long>, <long-int>345</long-int>, or
> <long_int>345</long_int>.
> 
> --tim
> 


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

Re: need help: cannot marshal

Posted by Tim Peierls <ti...@peierls.net>.
mike marsh wrote:
> Unfortunately, the other folks around me are python gurus. ...
> Zope and database browser1 both use the same python module for 
> xmlrpc, which obviously deviates from the xmlrpc standard.  

Deviant Python programmers, I figured it might be something like 
that. Just don't tell Dave Winer I told you any of this. :-)

XmlRpc.java, line 445, method startElement is the one that does the 
parsing, line 601, method characterData does the mapping. You would 
need to define another type constant, LONG, near line 145.

Going the other direction, XmlWriter.java, line 155, method writeObject
is the one that maps parameter values to XML elements.

These line numbers refer to the latest CVS snapshot.

One thing: <long int> isn't even valid XML, so make sure you know
exactly what tag the Python piece is expecting, probably something
like <long>345</long>, <long-int>345</long-int>, or <long_int>345</long_int>.

--tim


Re: need help: cannot marshal

Posted by Tim Peierls <ti...@peierls.net>.
mike marsh wrote:
> Unfortunately, the other folks around me are python gurus. ...
> Zope and database browser1 both use the same python module for 
> xmlrpc, which obviously deviates from the xmlrpc standard.  

Deviant Python programmers, I figured it might be something like 
that. Just don't tell Dave Winer I told you any of this. :-)

XmlRpc.java, line 445, method startElement is the one that does the 
parsing, line 601, method characterData does the mapping. You would 
need to define another type constant, LONG, near line 145.

Going the other direction, XmlWriter.java, line 155, method writeObject
is the one that maps parameter values to XML elements.

These line numbers refer to the latest CVS snapshot.

One thing: <long int> isn't even valid XML, so make sure you know
exactly what tag the Python piece is expecting, probably something
like <long>345</long>, <long-int>345</long-int>, or <long_int>345</long_int>.

--tim


Re: need help: cannot marshal

Posted by mike marsh <sa...@yahoo.com>.
Tim,

Thanks for your help.  I acknowledge your point--it IS
a limitation of the server.  Unfortunately, the other
folks around me are python gurus.  There are three
projects and three developers:

Zope Database (python)
Database Browser1 (python)
Database Browser2 (java)

I am implementing some great functionality into a
database browser2.  Zope and database browser1 both
use the same python module for xmlrpc, which obviously
deviates from the xmlrpc standard.  My java browser2
uses org.apache.xmlrpc.*, which obviously implements
the standard.

I'm not asking to have someone implement a change in
the release distribution to XmlRpc.java; I just want
some help me figure out how to change my copy so that
it can talk the bastardized xmlrpc that's being spoken
around here.

If you could point out to me where a parsed xmlrpc
type {base64, i4/int, boolean, string, struct, array,
dateTime.iso8601, double}, then I suppose that I could
add 'long int'.

thanks,
mike
--- Tim Peierls <ti...@peierls.net> wrote:
> mike marsh wrote:
> > I need to connect to a Zope database via XmlRpc.
> > Someone else maintains the xmlrpc methods and code
> on
> > the Zope server.  I try calling a particular
> method,
> > but an XmlRpcException gets thrown.  The exception
> > string says "cannot marshal <type 'long int'>".  I
> > suppose I need an XmlRpc parser that can interpret
> > <long int> and create a Long object.  
> 
> This is a limitation of the server, not of your
> client,
> so mucking with the client side parsing won't help
> you.
> 
> The XML-RPC spec (http://xmlrpc.org/spec) doesn't
> allow
> long integer values. The best you can do in general
> is 
> encode the long value as a string with 
> 
>     long value = ...;
>     String encodedValue = Long.toString(value);
> 
> and decode returned string values as longs with
> 
>     String value = ...;
>     long decodedValue;
>     try {
>         decodedValue = Long.parseLong(value);
>     }
>     catch (NumberFormatException e) {
>         decodedValue = 0; // or some sentinel value
>     }
> 
> But this all depends on the server doing the right
> thing
> with string-encoded long values. Check with the
> database 
> maintainer to find out how the Zope database can be
> used 
> via XML-RPC with non-XML-RPC types.
> 
> --tim
> 


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

Re: need help: cannot marshal

Posted by mike marsh <sa...@yahoo.com>.
Tim,

Thanks for your help.  I acknowledge your point--it IS
a limitation of the server.  Unfortunately, the other
folks around me are python gurus.  There are three
projects and three developers:

Zope Database (python)
Database Browser1 (python)
Database Browser2 (java)

I am implementing some great functionality into a
database browser2.  Zope and database browser1 both
use the same python module for xmlrpc, which obviously
deviates from the xmlrpc standard.  My java browser2
uses org.apache.xmlrpc.*, which obviously implements
the standard.

I'm not asking to have someone implement a change in
the release distribution to XmlRpc.java; I just want
some help me figure out how to change my copy so that
it can talk the bastardized xmlrpc that's being spoken
around here.

If you could point out to me where a parsed xmlrpc
type {base64, i4/int, boolean, string, struct, array,
dateTime.iso8601, double}, then I suppose that I could
add 'long int'.

thanks,
mike
--- Tim Peierls <ti...@peierls.net> wrote:
> mike marsh wrote:
> > I need to connect to a Zope database via XmlRpc.
> > Someone else maintains the xmlrpc methods and code
> on
> > the Zope server.  I try calling a particular
> method,
> > but an XmlRpcException gets thrown.  The exception
> > string says "cannot marshal <type 'long int'>".  I
> > suppose I need an XmlRpc parser that can interpret
> > <long int> and create a Long object.  
> 
> This is a limitation of the server, not of your
> client,
> so mucking with the client side parsing won't help
> you.
> 
> The XML-RPC spec (http://xmlrpc.org/spec) doesn't
> allow
> long integer values. The best you can do in general
> is 
> encode the long value as a string with 
> 
>     long value = ...;
>     String encodedValue = Long.toString(value);
> 
> and decode returned string values as longs with
> 
>     String value = ...;
>     long decodedValue;
>     try {
>         decodedValue = Long.parseLong(value);
>     }
>     catch (NumberFormatException e) {
>         decodedValue = 0; // or some sentinel value
>     }
> 
> But this all depends on the server doing the right
> thing
> with string-encoded long values. Check with the
> database 
> maintainer to find out how the Zope database can be
> used 
> via XML-RPC with non-XML-RPC types.
> 
> --tim
> 


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

Re: need help: cannot marshal

Posted by Tim Peierls <ti...@peierls.net>.
mike marsh wrote:
> I need to connect to a Zope database via XmlRpc.
> Someone else maintains the xmlrpc methods and code on
> the Zope server.  I try calling a particular method,
> but an XmlRpcException gets thrown.  The exception
> string says "cannot marshal <type 'long int'>".  I
> suppose I need an XmlRpc parser that can interpret
> <long int> and create a Long object.  

This is a limitation of the server, not of your client,
so mucking with the client side parsing won't help you.

The XML-RPC spec (http://xmlrpc.org/spec) doesn't allow
long integer values. The best you can do in general is 
encode the long value as a string with 

    long value = ...;
    String encodedValue = Long.toString(value);

and decode returned string values as longs with

    String value = ...;
    long decodedValue;
    try {
        decodedValue = Long.parseLong(value);
    }
    catch (NumberFormatException e) {
        decodedValue = 0; // or some sentinel value
    }

But this all depends on the server doing the right thing
with string-encoded long values. Check with the database 
maintainer to find out how the Zope database can be used 
via XML-RPC with non-XML-RPC types.

--tim


Re: need help: cannot marshal

Posted by Tim Peierls <ti...@peierls.net>.
mike marsh wrote:
> I need to connect to a Zope database via XmlRpc.
> Someone else maintains the xmlrpc methods and code on
> the Zope server.  I try calling a particular method,
> but an XmlRpcException gets thrown.  The exception
> string says "cannot marshal <type 'long int'>".  I
> suppose I need an XmlRpc parser that can interpret
> <long int> and create a Long object.  

This is a limitation of the server, not of your client,
so mucking with the client side parsing won't help you.

The XML-RPC spec (http://xmlrpc.org/spec) doesn't allow
long integer values. The best you can do in general is 
encode the long value as a string with 

    long value = ...;
    String encodedValue = Long.toString(value);

and decode returned string values as longs with

    String value = ...;
    long decodedValue;
    try {
        decodedValue = Long.parseLong(value);
    }
    catch (NumberFormatException e) {
        decodedValue = 0; // or some sentinel value
    }

But this all depends on the server doing the right thing
with string-encoded long values. Check with the database 
maintainer to find out how the Zope database can be used 
via XML-RPC with non-XML-RPC types.

--tim