Subject: | Sending an XML string using SOAP::Lite doesn't work |
The attached patch adds some tests to the SOAP::Lite test suite that attempt to serialize and deserialize an XML string. These tests fail using perl 5.8.3, SOAP::Lite 0.66 on Debian Linux, expat 1.95.8-3.
These tests die with:-
"xml declaration not at start of external entity at line 1, column 391, byte 391 at /opt/perl/lib/site_perl/5.8.3/XML/Parser.pm line 187"
I'm not at all familiar with the SOAP::Lite internals or with the test suite - so I *believe* that these tests are correctly demonstrating my problem, however please let me know if there are any problems.
diff -urN SOAP-Lite-0.66.orig/t/01-core.t SOAP-Lite-0.66.new/t/01-core.t
--- SOAP-Lite-0.66.orig/t/01-core.t 2005-05-15 21:22:37.000000000 +0100
+++ SOAP-Lite-0.66.new/t/01-core.t 2006-01-03 13:43:54.000000000 +0000
@@ -10,7 +10,7 @@
use strict;
use Test;
-BEGIN { plan tests => 35; }
+BEGIN { plan tests => 49; }
use SOAP::Lite;
@@ -275,3 +275,52 @@
$ret = $deserializer->deserialize($input);
ok("one" eq $ret->result->{'complexFoo'}{'arrayFoo'});
}
+
+
+
+
+# Check that serialization and deserialization of XML strings works OK too
+#
+{
+ # Firstly, check that this works for normal data....
+ print "Testing serialization / deserialization of XML entities part 1... \n";
+
+ my @args = ("bob", (bless { "name" => "Bob" }, "My::Module"), 27, "<hello>World!</hello>");
+ my $serializer = SOAP::Serializer->new();
+ my $deserializer = SOAP::Deserializer->new();
+ my $out = $deserializer->deserialize($serializer->serialize(\@args))->root;
+ ok(ref($out), "ARRAY");
+ ok($out->[0], "bob");
+ ok(UNIVERSAL::isa($out->[1], "My::Module"));
+ ok($out->[1]->{name}, "Bob");
+ ok($out->[2], 27);
+ ok($out->[3], "<hello>World!</hello>");
+}
+
+{
+ print "Testing serialization / deserialization of XML entities part 2... \n";
+
+ # Now make one of our thingies an XML string that includes a namespace
+ my @args = ("bob", '<hello xmlns:bob="http://www.example.com/bob">World!</hello>', "Bobbage");
+ my $serializer = SOAP::Serializer->new();
+ my $deserializer = SOAP::Deserializer->new();
+ my $out = $deserializer->deserialize($serializer->serialize(\@args))->root;
+ ok(ref($out), "ARRAY");
+ ok($out->[0], $args[0]);
+ ok($out->[1], $args[1]);
+ ok($out->[2], $args[2]);
+}
+
+{
+ print "Testing serialization / deserialization of XML entities part 3... \n";
+
+ # Finally, add an xml header, and watch things die.....
+ my @args = ("bob", '<?xml version="1.0" encoding="UTF-8"?><hello xmlns:bob="http://www.example.com/bob">World!</hello>', "Bobbage");
+ my $serializer = SOAP::Serializer->new();
+ my $deserializer = SOAP::Deserializer->new();
+ my $out = $deserializer->deserialize($serializer->serialize(\@args))->root;
+ ok(ref($out), "ARRAY");
+ ok($out->[0], $args[0]);
+ ok($out->[1], $args[1]);
+ ok($out->[2], $args[2]);
+}