Click here to get back home

SOAP::Lite weirdness

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
SOAP::Lite weirdness Gabriel 04-06-2006
Posted by Gabriel on April 6, 2006, 8:07 am
Please log in for more thread options


I am writing a SOAP client, and I've been having difficulties using
SOAP::Lite to work properly with the supplied service. I have a sample
SOAP request, which was created using PHP, and I know that it works, so
I simply need to 'copy' it with perl, in order to get it working,
right?

Anyway, this is what the successful PHP-composed SOAP envelope looks
like:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns4="http://www.freshdigital.co.uk/mediastore">
<SOAP-ENV:Body>
<ns4:search>
<ns4:session>$SESSIONID</ns4:session>
<ns4:searchTerms>
<ns4:item>
<ns4:key>ARTISTID</ns4:key>
<ns4:value>2047</ns4:value>
<ns4:like>true</ns4:like>
</ns4:item>
</ns4:searchTerms>
<ns4:searchType>OR</ns4:searchType>
<ns4:offset>0</ns4:offset>
<ns4:count>50</ns4:count>
</ns4:search>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

(the $SESSIONID bit should actually contain a valid sessionID, which I
removed for this public posting)
And the documentation says this about their 'search' functionality.
requires: sessionid, searchTerms (an array of search criteria),
searchtype (AND or OR), offset, and count.

anyway, this is the perl code I used to 'emulate' this SOAP call.

my @searchterms = (
SOAP::Data->name("searchTerms" =>
\SOAP::Data->value(SOAP::Data->name("item" =>
[

SOAP::Data->type('string')->name('key')->value('GENRE'),

SOAP::Data->type('string')->name('value')->value('rock'),

SOAP::Data->type('boolean')->name('like')->value('true')
]
))
)
);
my $result = $soap->search( $sessionID, @searchterms, "OR", 0, 10 );

which results in this SOAP envelope being passed on to the SOAP
service:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<namesp2:search
xmlns:namesp2="http://www.freshdigital.co.uk/mediastore">
<session xsi:type="xsd:string">$SESSIONID</session>
<searchTerms>
<item xsi:type="SOAP-ENC:Array"
SOAP-ENC:arrayType="xsd:anyType[3]">
<key xsi:type="xsd:string">GENRE</key>
<value xsi:type="xsd:string">rock</value>
<like xsi:type="xsd:boolean">true</like>
</item>
</searchTerms>
<searchType xsi:type="xsd:string">OR</searchType>
<offset xsi:type="xsd:int">0</offset>
<count xsi:type="xsd:int">10</count>
</namesp2:search>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

(once again, I have changed the real sessionID to $SESSIONID, for
privacy reasons).
which, while being more verbose, appears (to me) to be much the same
thing.
Unfortunately, I get this (not very useful) error message from the
service, after submitting the above search request:

<faultcode>soapenv:Server.userException</faultcode>
<faultstring>java.lang.ArrayStoreException:
[Ljava.lang.Object;</faultstring>
<detail>
<ns1:hostname
xmlns:ns1="http://xml.apache.org/axis/">bridgaa2</ns1:hostname>
</detail>

So it looks like some kind of problem with the array, but other than
that, I have no idea what I am doing wrong. Perhaps someone more
experienced with SOAP can point out my obvious mistake, or what the
problem may be.

My apologies if this post has been a bit verbose with the XML, but I
felt it was necessary in order to figure out the problem.


Posted by Gabriel on April 6, 2006, 10:16 am
Please log in for more thread options


well, I officially feel like a dolt now.
The 'problem' was that I was using two arrays, and I should have been
using one.
This is what my code should have looked like:

my $searchterms = SOAP::Data->name(searchTerms =>
\SOAP::Data->name(item =>
\SOAP::Data->value(
SOAP::Data->name(key => 'ARTISTID'),
SOAP::Data->name(value => '2047')->type('string'),
SOAP::Data->name(like => 'true')->type('boolean'),
)
)
);
my $result = $soap->search( $sessionID, $searchterms, "OR", 0, 10 );


Sorted. Thanks anyway, to all who may have taken the time to read my
post, its appreciated all the same.


Similar ThreadsPosted
SOAP::Lite : Problem of # sign added by SOAP::Lite in the sent SOAPActionstring November 5, 2004, 8:45 pm
SOAP::Lite WSDL method with multiple soap:body parts February 16, 2005, 3:32 pm
Writing a HTML/ASP SOAP client for a SOAP::Lite destination March 16, 2005, 5:19 pm
Help with SOAP::Lite January 19, 2005, 11:35 pm
SOAP::Lite March 3, 2005, 6:13 am
Using SOAP::Lite and .NET November 16, 2005, 2:12 pm
SOAP::Lite March 5, 2007, 4:26 am
use SOAP::Lite +autodispatch ??? November 23, 2004, 3:12 am
ForkOnAccept for SOAP::Lite TCP server November 27, 2004, 11:32 am
Soap::Lite Cant get array of results? March 30, 2005, 12:43 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap