Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

SOAP::Lite and XML

by cerror (Scribe)
on Jul 03, 2007 at 01:46 UTC ( #624578=perlquestion: print w/replies, xml ) Need Help??

cerror has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I know I'm kind of rehashing an old node, but I've made some progress and would like some advice on how to proceed from here. I think the problem I've been having may be in the way SOAP::Lite serializes the array, though I may be mistaken. Here's the relevant offending code from my XRC module as it is now:
sub changePkg { my ($username, $pkg) = @_; my $client = connectXrc(); my $result = $client->setUserOffers( XRC_CLIENTID, $username, $pkg); }
The wsdl file defines setUserOffers like so:
<wsdl:message name="setUserOffersRequest"> <wsdl:part name="clientID" type="xs:int"/> <wsdl:part name="username" type="xs:string"/> <wsdl:part name="offerIDs" type="types:ArrayOfInt"/> </wsdl:message>
And ArrayOfInt like this:
<xs:complexType name="ArrayOfInt"> <xs:annotation><![CDATA[ A SOAP encoded array of the xs:int type. ]]></xs:annotation> <xs:complexContent> <xs:restriction base="soapenc:Array"> <xs:attribute ref="soapenc:arrayType" wsdl:arrayType="xs:int[]"/ +> </xs:restriction> </xs:complexContent> </xs:complexType>
My test, which fails, is very simple. The relevant parts look like this:
my @pkg = 5544; print "username: "; my $username = <STDIN>; chomp($username); XRC::changePkg($username, @pkg);
Everything works except offerIDs (@pkg). My XML that's passed to the server defines it like this:
<offerIDs xsi:type="types:ArrayOfInt">5544</offerIDs>
However, it always fails with this fault:
<faultstring>org.xml.sax.SAXException: Found character data inside an +array element while deserializing</faultstring>
I know I'm not actually passing a string, so I'm not really certain what's going on here. Google gave me some ideas, which I tested, but nothing ultimately came of it. Does anyone else have a suggestion?

Thanks!
- cerror

Replies are listed 'Best First'.
Re: SOAP::Lite and XML
by rhesa (Vicar) on Jul 03, 2007 at 02:25 UTC
    Similar to your previous node, try passing a reference to the @pkg array:
    XRC::changePkg( $username, \@pkg );
    I still don't have access to the required wsdl file, so it's a bit of a guess, but here's what SOAP::Lite generates for the array without the wsdl:
    <soapenc:Array soapenc:arrayType="xsd:int[1]" xsi:type="soapenc:Array" +> <item xsi:type="xsd:int">5544</item> </soapenc:Array>
    I think you'll find it'll turn out alright when the wsdl is in place.
      When I do that, I end up passing:
      <offerIDs soapenc:arrayType="xsd:int[1]" xsi:type="types:ArrayOfInt">< +item xsi:type="xsd:int">5544</item></offerIDs>
      and the fault is:
      <faultstring>org.xml.sax.SAXException: No deserializer for int</faults +tring>
      I tried almost every permutation I could think of. I've posted the entire wsdl file here if you think it'll help (minus the actual username/password).

      Thanks for all your help so far. :-)
      - cerror
Re: SOAP::Lite and XML
by ForgotPasswordAgain (Priest) on Jul 03, 2007 at 08:31 UTC

    You seem to be using Java Axis. Are you able to use the WSDL from a Java client to call the server, instead of SOAP::Lite?

    I'm not a WSDL expert or anything, but yours doesn't look right to me. I'd think you'd need another <element> definition in there for each thing inside of the <offerIDs> element, like

    <xs:complexType name="ArrayOfInt"> <xs:complexContent> <xs:restriction base="soapenc:Array"> <xs:sequence> <!-- NB: adding 'item' elements here --> <xs:element name="item" type="xsd:int"/> </xs:sequence> <xs:attribute ref="soapenc:arrayType" wsdl:arrayType="xs:int[]"/ +> </xs:restriction> </xs:complexContent> </xs:complexType

    I could easily be wrong about that, though.

Re: SOAP::Lite and XML
by philcrow (Priest) on Jul 03, 2007 at 13:18 UTC
    If your WSDL is publicly visible on the web, you might be able to use www.xmethods.net to test correct usages. It worked for me once upon a time. I don't know their terms of service, but they have many examples they offer to test for you.

    Sometimes SOAP::Lite is more cumbersome than template toolkit or a simple here doc. The key is to find out what a good packet looks like to the server. Then you can template it.

    Phil

    The Gantry Web Framework Book is now available.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://624578]
Approved by jesuashok
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2023-02-04 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (31 votes). Check out past polls.

    Notices?