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