Is it possible to get SOAP::Lite to return an array that conforms to what folks have defined in a WSDL file?
I'm trying to get SOAP::Lite to produce something like:
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instanc
+e"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<namesp1:doGetClientListResponse xmlns:namesp1="urn:iReserve">
<records xsi:type="typens:ClientRecordList">
<ClientArray SOAP-ENC:arrayType="typens:ClientRecord[2]"
xsi:type="SOAP-ENC:Array">
<ClientRecord xsi:type="typens:ClientRecord">
<id xsi:type="xsd:Int">1</id>
<name xsi:type="xsd:String">Bob's Low Cost Insurance</name>
</ClientRecord>
<ClientRecord xsi:type="typens:ClientRecord">
<id xsi:type="xsd:Int">2</id>
<name xsi:type="xsd:String">Tom's Great Insurance</name>
</ClientRecord>
</ClientArray>
</records>
</namesp1:doGetClientListResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
using this routine
sub doGetClientList {
# deal with arguments
# warn Dumper(\@_);
shift; # remove class name
my $cookie = shift; # unused currently
# talk to database
my $dbh = _dbh();
my $sql = "select * from client";
my $sth = $dbh->prepare($sql) or die "prep $sql";
$sth->execute() or die "exec $sql";
my $clientlist = [];
while (my $row = $sth->fetchrow_hashref()) {
# my $soapclientrec = SOAP::Data->new();
# $soapclientrec->name('clientrecord');
# $soapclientrec->type('typens:ClientRecord');
push(@$clientlist,$row);
}
warn "PID=$$ " . Dumper($clientlist);
# warn "PID=$$ clients=(" . join(',',@$clientlist) . ")";
# warn "here";
# return ({records=>$clientlist});
# return SOAP::Data->name("records" =>
# SOAP::Data->value( SOAP::Data->name("client" => @$clie
+ntlist)
# ->type("ClientRecord")
# )
# )->type("ClientRecordArray");
my @soaprecs;
foreach my $row (@$clientlist) {
foreach my $key (keys %$row) {
unless (defined $row->{$key}) {
$row->{$key} = '';
}
}
my $clirec = SOAP::Data->new();
$clirec->name('ClientRecord');
#$clirec->value($row->{clientid});
$clirec->value($row);
$clirec->type('typens::ClientRecord');
push(@soaprecs,$clirec);
}
#warn Dumper(\@soaprecs);
my $reccount = scalar(@soaprecs);
my $clientarray = SOAP::Data->new();
$clientarray->name('ClientArray');
# $clientarray->value(@soaprecs);
$clientarray->value('blah blah');
$clientarray->attr({'SOAP-ENC:arrayType'=>"typens:ClientRecord[$re
+ccount]",
# 'xsi:type' => 'SOAP-ENC:Array',
});
$clientarray->type('SOAP-ENC:Array',);
my $records = SOAP::Data->new();
$records->name('records');
$records->value($clientarray);
$records->type('typens:ClientRecordList');
# warn "about to encode array";
# use warnings;
# my $serializer = SOAP::Serializer->new();
# warn "got serializer";
# my $records = $serializer->encode_array($clientlist,'clientlist',
+'ClientRecordArray',{});
# my $records = $serializer->encode_object($clientlist,'clientlist'
+,'ClientRecordArray');
# warn Dumper($records);
return $records;
}
I left the various incantations I've tried commented out. So my questions would be these:
1) Is it possible to use SOAP::Lite to produce that SOAP Message above?
2) If it won't do it natively how can I override it's output so I can wack it into shape by hand?
3) Is there any Perl SOAP implementation which validates what the server side is doing against a given WSDL?
4) Should I just give up on SOAP and do something else to move arbitarily complex data structures back and forth between a client written in Mozilla XUL and a server written in Perl?
Any guidance would be greatly appreciated.
janitored by ybiC: Replaced <pre> tags with <code> and wrapped longish codeblock in balanced <readmore> tags, all per Monastery convention