On Nov 26, 10:31 pm, Todd Wade <waveri...@gmail.com> wrote:
> On Nov 26, 7:19 pm, Darcy <darcyka...@gmail.com> wrote:
>
>
>
> > On Nov 26, 5:22 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> > > Quoth Darcy <darcyka...@gmail.com>:
>
> > > > I am trying to write an XML-RPC server method in perl using RPC::XML,
> > > > and I am having a rather perplexing problem when I attempt to return a
> > > > data structure to the caller (a Java app). I am told that the caller
> > > > is expecting an array of structs as the result.
> <snip/>
> > > > This is the error that the Java app is generating when it receives the
> > > > response:
>
> > > > ERROR 26 Nov 2007 16:56:50
> > > > (org.wh.client.frontend.listener.WHAbstractFrontEn dActionListener) -
> > > > java.lang.ClassCastException: java.lang.Integer
>
> > > Just a completely random guess: have you tried using numbers instead of
> > > strings? That is,
>
> > > return [{
> > > SELL_LINE_NUMBER => 1, # note absence of quotes
> > > ERROR_CODE => 0,
> > > MESSAGE => 'test',
> > > CURRENT_TOTAL => 1,
> > > }];
>
> > The reason for quoting the numbers, is because, the specs for the
> > return list all four as "string". I did try as straight numbers, but
> > got the same error.
>
> What does the XML that client sending to the server look like? Thats
> what you need to be looking at. For example, you said the spec expects
> strings for each value. Chances are that "quoting" the numbers isn't
> going to suffice RPC::XML's purposes.
>
> You can coerce a value to a specific type by passing RPC::XML data
> objects instead of scalars:
>
> return [{
> SELL_LINE_NUMBER => RPC::XML::string->new(1),
> ERROR_CODE => RPC::XML::string->new(0),
> MESSAGE => 'test',
> CURRENT_TOTAL => RPC::XML::string->new(1),
> }];
>
> This will format the value as a <string> instead of an <int> in the
> XML.
>
> Regards,
>
> trwww
Thanks. I will try that tomorrow. I do not know what the XML that is
being generated, though, since I currently do not have access to
that. I could try and "fudge" the request, so I can see the result,
unless there is a trick in perl where I could save a copy to file as
well as send to the requestor.
|