This post originated from an RSS feed registered with Java Buzz
by Chris Winters.
Original Post: Deserializing Java Vectors with SOAP::Lite
Feed Title: cwinters.com
Feed URL: http://www.cwinters.com/search/registrar.php?domain=jroller.com®istrar=sedopark
Feed Description: Chris Winters on Java, programming and technology, usually in that order.
I'm seriously using SOAP for the first time and came to a stumbling block. I'm testing a SOAP interface with SOAP::Lite since it's is supposed to be available from different environments/languages. But one of the methods I'm calling has the signature:
public Vector fetchAllThingies()...
It's really just an array so it should be a piece of cake, right? Nope. SOAP::Lite doesn't seem to support multiple return values, or a single return value representing multiple objects. Everything seems to work, but if you ask for the result you only get the last item.
After floundering for a bit I found a soaplite mailing list post from Paul that basically said, "Yeah, we don't do that, but here's another way." Using that you should be able to get into a Vector of simple hashtables (probably Objects too, haven't tested yet) with this not-necessarily-definitive fix:
my $result = SOAP::Lite->new()
->uri( 'urn:SomeThingies' )
->proxy( 'http://somehost/SOAP' )
->fetchAllThingies();
# '//return/item' is an XPath expression...
my @thingies = $result->valueof( '//return/item' );
foreach my $thingy ( @thingies ) {
# $thingy isa hashref with keys/values as you'd expect
}
We'll see what more fun awaits... but a positive benefit of being exposed to SOAP is that I'll understand how this OpenInteract2 handler works and hopefully put it in the next version.