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

I got a web service with a function that takes in an array of int's and returns a complex array. Here's the snippet of perl code:
=begin WSDL _IN smis @int session message id's to get data for _RETURN @SmiData smi data for each existing modality =end WSDL =cut sub getSmisData { my $class = shift; my (@smis) = @_; my $smiData = []; my $dbh = open_db(); if ($dbh) { # do something } else { # do something else } return ($smiData); }
Pod::WSDL generates a wsdl containing (partially):
<complexType name="ArrayOfInt"> <complexContent> <restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:arrayT +ype="soapenc:int[]" /> </restriction> </complexContent> </complexType> <complexType name="ArrayOfSmiData"> <complexContent> <restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:arrayT +ype="tns1:SmiData[]" /> </restriction> </complexContent> </complexType> <wsdl:message name="getSmisDataRequest"> <wsdl:part name="smis" type="tns1:ArrayOfInt"> <wsdl:documentation>session message id's to get data for</ +wsdl:documentation> </wsdl:part> </wsdl:message> <wsdl:message name="getSmisDataResponse"> <wsdl:part name="getSmisDataReturn" type="tns1:ArrayOfSmiData" +> <wsdl:documentation>smi data for each existing modality</w +sdl:documentation> </wsdl:part> </wsdl:message>
I am using soapUI to test the wsdl. It automatically generates a request (partial):
<soapenv:Body> <heal:getSmisData soapenv:encodingStyle="http://schemas.xmlsoap. +org/soap/encoding/"> <smis xsi:type="heal:ArrayOfInt" soapenc:arrayType="soapenc:i +nt[2]" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> <xsd:int>111</xsd:int> <xsd:int>222</xsd:int> </smis> </heal:getSmisData> </soapenv:Body>
The response to this is as if the function did not find any data and looks like (partial):
<soap:Body> <getSmisDataResponse xmlns="http://monitor.site.local/HealthWS"> <soapenc:Array soapenc:arrayType="xsd:anyType[0]" xsi:type="s +oapenc:Array"/> </getSmisDataResponse>
However, if i change the request to (partial):
<soapenv:Body> <heal:getSmisData soapenv:encodingStyle="http://schemas.xmlsoap. +org/soap/encoding/"> <xsd:int>111</xsd:int> <xsd:int>222</xsd:int> </heal:getSmisData> </soapenv:Body>
(ie remove the array notion) i do get correct data for provided id's.

What is wrong with this? Is it the request or the wsdl issue? Any suggestions?

Thank you all in advance!

Replies are listed 'Best First'.
Re: Pod::WSDL array question
by Anonymous Monk on Jan 15, 2009 at 17:17 UTC
    Found the issue myself - it was in the perl function. It was getting an array, whereas it needed to expect a reference to array. The wsdl =begin =end definitions stay the same though:
    =begin WSDL _IN smis @int session message id's to get data for _RETURN @SmiData smi data for each existing modality =end WSDL =cut sub getSmisData { my $class = shift; my ($smis) = @_; # not @smis my $smiData = []; my $dbh = open_db(); if ($dbh) { # do something } else { # do something else } return ($smiData); }
    Thank you all for trying.