File: rt72836.t

package info (click to toggle)
libsoap-lite-perl 1.27-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 1,680 kB
  • sloc: perl: 8,908; makefile: 23; cs: 16
file content (53 lines) | stat: -rw-r--r-- 2,515 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use strict;
use warnings;

package DoThingsWithStuff;

use SOAP::Lite;
our @ISA = qw(SOAP::Server::Parameters);

sub new {
    my ( $class ) = @_;
    my $self = bless {}, ref($class) || $class;
    $self;
}

sub do_something {
    my $self = shift;
    my $som = pop;
    #$som->context->serializer->encodingStyle(""); # does adding this affect the fix?
    return SOAP::Data->name(wotsit => "doofer");
}

package main;

use Test::More;
use SOAP::Lite;
eval { require Test::XML }
    or plan skip_all => 'Cannot test without Test::XML';

my $req11 = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Something"><soapenv:Header/><soapenv:Body><urn:do_something><stuff>things</stuff></urn:do_something></soapenv:Body></soapenv:Envelope>';

my $req12 = '<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:Something"><soapenv:Header/><soapenv:Body><urn:do_something><stuff>things</stuff></urn:do_something></soapenv:Body></soapenv:Envelope>';

my $expected_11 = '<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><do_somethingResponse xmlns="urn:Something"><wotsit xsi:type="xsd:string">doofer</wotsit></do_somethingResponse></soap:Body></soap:Envelope>';

my $expected_12 = '<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><do_somethingResponse xmlns="urn:Something"><wotsit xsi:type="xsd:string">doofer</wotsit></do_somethingResponse></soap:Body></soap:Envelope>';

my $t = DoThingsWithStuff->new;

my $s = SOAP::Server->new;
$s->dispatch_with({
    "urn:Something" => $t
});

my $res_11_1 = $s->handle($req11);
Test::XML::is_xml($res_11_1, $expected_11, "Got correct SOAP 1.1 response");

my $res_12 = $s->handle($req12);
Test::XML::is_xml($res_12, $expected_12, "Got correct SOAP 1.2 response");

my $res_11_2 = $s->handle($req11);
Test::XML::is_xml($res_11_2, $expected_11, "Got correct SOAP 1.1 response after processing a SOAP 1.2 request");

done_testing;