Replying to myself, I figured this out in the time it took the message
to come back to my inbox. The mistake was including the "soap:..."
strings in the path of the dataof function. Replace with the following
and everything's cool:
my $user = $envelope->dataof('/Envelope/Body/purgeTest/user');
-C
On May 3, 2008, at 9:29 PM, Chris Woodfield wrote:
> Hello,
>
> I have a script that sends the following XML to a web service:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/
> ">
> <soap:Body>
> <purgeTest xmlns="http://tino.semihuman.com/PurgeTest">
> <user xsi:type="xsd:string">foo</user>
> </purgeTest>
> </soap:Body>
> </soap:Envelope>
>
> And the following code to try to pull out the <user> tag and return
> it:
>
> ----
> #!/usr/bin/perl -w
>
> use strict;
>
> use vars qw(@ISA);
> @ISA = qw(Exporter SOAP::Server::Parameters);
>
> package PurgeTest;
>
> use vars qw(@ISA);
> @ISA = qw(Exporter SOAP::Server::Parameters);
> use SOAP::Lite;
> use Data::Dumper;
>
> sub purgeTest {
> my $self = shift;
> my $envelope = pop;
>
> my $user = $envelope->dataof('/soap:Envelope/soap:Body/purgeTest/
> user');
>
> return SOAP::Data->name('user' => $user->value);
>
> }
>
> 1;
> ---
>
> The code doesn't appear to be working, however; the $user variable
> never gets a value and the return function fails with the below in the
> faultstring:
>
> Could not communicate with web service: Can't call method "value" on
> an undefined value at /usr/lib/cgi-bin/PurgeTest.pm line 21. (that's
> the "return SOAP::Data... line). If I try to print $user as a test it
> is undef.
>
> I get the impression I'm missing something simple here. Any ideas?
>
> Thanks,
>
> -Chris
>
>
>