Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

SOAP::Lite can produce exact tag structure response?

by chicks (Scribe)
on Sep 17, 2004 at 23:12 UTC ( [id://391918]=perlquestion: print w/replies, xml ) Need Help??

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

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

Replies are listed 'Best First'.
Re: SOAP::Lite can produce exact tag structure response?
by chicks (Scribe) on Sep 18, 2004 at 09:49 UTC
    ybiC said:

    janitored by ybiC: Replaced <pre> tags with <code> and wrapped longish codeblock in balanced <readmore> tags, all per Monastery convention

    Thank you very much.

    I will follow these conventions! Sorry for not realizing.

Re: SOAP::Lite can produce exact tag structure response?
by StoneTable (Beadle) on Sep 18, 2004 at 20:21 UTC

    I just finished something similar to this, where I was trying to get a SOAP::Lite server to work with a .NET client.

    I ended up using SOAP::Data::Builder to build the appropriate return values in the way expected by the WSDL I defined for the client.

    Hope this helps.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-24 20:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found