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

Hello, perl 5.18.2 SOAP::Lite 1.11 I'm trying to use SOAP::Lite to deserialize its own output, but I get an exception. Can someone please suggest how I might change the serializer or deserializer to resolve this issue. Solutions that are likely to be compatible with other SOAP desierializers are preferred. Thank you!
$ cat test.pl use strict; use warnings; use SOAP::Lite; print "\$SOAP::Lite::VERSION: $SOAP::Lite::VERSION\n"; my $writer = SOAP::Serializer->new(); my $fault = SOAP::Fault->new(faultcode => "Server"); my $content = $writer->envelope(fault => $fault); print $content, "\n"; eval { SOAP::Deserializer->deserialize($content); }; if ($@) { print "Deserialize failed: $@"; } $ perl test.pl $SOAP::Lite::VERSION: 1.11 Use of uninitialized value in join or string at /home/vagrant/perl5/pe +rlbrew/perls/perl-5.18.2-fPIC/lib/site_perl/5.18.2/SOAP/Lite.pm line +520. Use of uninitialized value in join or string at /home/vagrant/perl5/pe +rlbrew/perls/perl-5.18.2-fPIC/lib/site_perl/5.18.2/SOAP/Lite.pm line +520. Use of uninitialized value in join or string at /home/vagrant/perl5/pe +rlbrew/perls/perl-5.18.2-fPIC/lib/site_perl/5.18.2/SOAP/Lite.pm line +520. Argument "Server: " isn't numeric in sprintf at /home/vagrant/perl5/pe +rlbrew/perls/perl-5.18.2-fPIC/lib/site_perl/5.18.2/SOAP/Lite.pm line +1033. Use of uninitialized value $name in substitution (s///) at /home/vagra +nt/perl5/perlbrew/perls/perl-5.18.2-fPIC/lib/site_perl/5.18.2/SOAP/Li +te.pm line 1100. Use of uninitialized value $name in exists at /home/vagrant/perl5/perl +brew/perls/perl-5.18.2-fPIC/lib/site_perl/5.18.2/SOAP/Lite.pm line 11 +01. Use of uninitialized value $name in hash element at /home/vagrant/perl +5/perlbrew/perls/perl-5.18.2-fPIC/lib/site_perl/5.18.2/SOAP/Lite.pm l +ine 1101. Use of uninitialized value $name in hash element at /home/vagrant/perl +5/perlbrew/perls/perl-5.18.2-fPIC/lib/site_perl/5.18.2/SOAP/Lite.pm l +ine 1105. Use of uninitialized value $name in hash element at /home/vagrant/perl +5/perlbrew/perls/perl-5.18.2-fPIC/lib/site_perl/5.18.2/SOAP/Lite.pm l +ine 1105. Use of uninitialized value in join or string at /home/vagrant/perl5/pe +rlbrew/perls/perl-5.18.2-fPIC/lib/site_perl/5.18.2/SOAP/Lite.pm line +520. Argument "Server: " isn't numeric in sprintf at /home/vagrant/perl5/pe +rlbrew/perls/perl-5.18.2-fPIC/lib/site_perl/5.18.2/SOAP/Lite.pm line +1033. <?xml version="1.0" encoding="UTF-8"?><soap:Envelope soap:encodingStyl +e="http://schemas.xmlsoap.org/soap/encoding/" xmlns:namesp1="http://n +amespaces.soaplite.com/perl" xmlns:soap="http://schemas.xmlsoap.org/s +oap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encodin +g/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://ww +w.w3.org/2001/XMLSchema-instance"><soap:Body><soap:Fault><faultcode x +si:type="namesp1"><_faultcode xsi:type="xsd:string">Server</_faultcod +e></faultcode><faultstring xsi:nil="true" /></soap:Fault></soap:Body> +</soap:Envelope> Deserialize failed: Unspecified namespace for type 'namesp1'

Replies are listed 'Best First'.
Re: Why can't SOAP::Lite deserialize its own output?
by boftx (Deacon) on Jul 03, 2014 at 03:47 UTC

    I am guessing that this line:

    Argument "Server: " isn't numeric in sprintf at /home/vagrant/perl5/pe +rlbrew/perls/perl-5.18.2-fPIC/lib/site_perl/5.18.2/SOAP/Lite.pm line +1033
    is pointing to the culprit. Is Server the correct type of argument for fault?

    What happens if you change
    my $content = $writer->envelope(fault => $fault);
    to this?
    my $content = $writer->envelope(fault => '');
    You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.
      Same exception if the faultcode is "" or 0.

        Look for namesp1 in the docs for SOAP::Lite. There might be some info there for the error msg from the failed eval (especially in the sections on use_prefix and Disable use of explicit namespace prefixes.

        You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.
Re: Why can't SOAP::Lite deserialize its own output? (it does)
by Anonymous Monk on Jul 03, 2014 at 07:57 UTC