XMLRPC-Lite-0.717/000755 000765 000765 00000000000 12145606566 013723 5ustar00phredphred000000 000000 XMLRPC-Lite-0.717/Changes000644 000765 000765 00000000244 12145306331 015201 0ustar00phredphred000000 000000 Revision history for Perl extension Perl-XMLRPC-Lite. 0.01 Thu May 16 18:50:17 2013 - original version; created by h2xs 1.23 with options -X perl-XMLRPC-Lite XMLRPC-Lite-0.717/lib/000755 000765 000765 00000000000 12145606566 014471 5ustar00phredphred000000 000000 XMLRPC-Lite-0.717/Makefile.PL000644 000765 000765 00000000573 12145310153 015662 0ustar00phredphred000000 000000 #!/usr/bin/perl use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'XMLRPC-Lite', VERSION_FROM => 'lib/XMLRPC/Lite.pm', PREREQ_PM => { 'SOAP::Lite' => 0.716, 'SOAP::Transport::TCP' => 0.715 }, ABSTRACT_FROM => 'lib/XMLRPC/Lite.pm', AUTHOR => 'Paul Kulchenko (paulclinger@yahoo.com)' ); XMLRPC-Lite-0.717/MANIFEST000644 000765 000765 00000000630 12145606567 015054 0ustar00phredphred000000 000000 Changes Makefile.PL MANIFEST README lib/Apache/XMLRPC/Lite.pm lib/XMLRPC/Lite.pm lib/XMLRPC/Test.pm lib/XMLRPC/Transport/HTTP.pm lib/XMLRPC/Transport/POP3.pm lib/XMLRPC/Transport/TCP.pm t/07-xmlrpc_payload.t t/26-xmlrpc.t t/37-mod_xmlrpc.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) XMLRPC-Lite-0.717/META.json000644 000765 000765 00000001677 12145606566 015357 0ustar00phredphred000000 000000 { "abstract" : "client and server implementation of XML-RPC protocol", "author" : [ "Paul Kulchenko (paulclinger@yahoo.com)" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120630", "license" : [ "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "XMLRPC-Lite", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "SOAP::Lite" : "0.716", "SOAP::Transport::TCP" : "0.715" } } }, "release_status" : "stable", "version" : "0.717" } XMLRPC-Lite-0.717/META.yml000644 000765 000765 00000001055 12145606566 015175 0ustar00phredphred000000 000000 --- abstract: 'client and server implementation of XML-RPC protocol' author: - 'Paul Kulchenko (paulclinger@yahoo.com)' build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120630' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: XMLRPC-Lite no_index: directory: - t - inc requires: SOAP::Lite: 0.716 SOAP::Transport::TCP: 0.715 version: 0.717 XMLRPC-Lite-0.717/README000644 000765 000765 00000003133 12145307276 014577 0ustar00phredphred000000 000000 NAME XMLRPC::Lite - client and server implementation of XML-RPC protocol SYNOPSIS Client use XMLRPC::Lite; print XMLRPC::Lite -> proxy('http://betty.userland.com/RPC2') -> call('examples.getStateStruct', {state1 => 12, state2 => 28}) -> result; CGI server use XMLRPC::Transport::HTTP; my $server = XMLRPC::Transport::HTTP::CGI -> dispatch_to('methodName') -> handle ; Daemon server use XMLRPC::Transport::HTTP; my $daemon = XMLRPC::Transport::HTTP::Daemon -> new (LocalPort => 80) -> dispatch_to('methodName') ; print "Contact to XMLRPC server at ", $daemon->url, "\n"; $daemon->handle; DESCRIPTION XMLRPC::Lite is a Perl modules which provides a simple nterface to the XML-RPC protocol both on client and server side. Based on SOAP::Lite module, it gives you access to all features and transports available in that module. See t/26-xmlrpc.t for client examples and examples/XMLRPC/* for server implementations. DEPENDENCIES SOAP::Lite SEE ALSO SOAP::Lite CREDITS The XML-RPC standard is Copyright (c) 1998-2001, UserLand Software, Inc. See for more information about the XML-RPC specification. COPYRIGHT Copyright (C) 2000-2001 Paul Kulchenko. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHOR Paul Kulchenko (paulclinger@yahoo.com) XMLRPC-Lite-0.717/t/000755 000765 000765 00000000000 12145606566 014166 5ustar00phredphred000000 000000 XMLRPC-Lite-0.717/t/07-xmlrpc_payload.t000644 000765 000765 00000003637 12145307253 017615 0ustar00phredphred000000 000000 #!/bin/env perl BEGIN { unless(grep /blib/, @INC) { chdir 't' if -d 't'; unshift @INC, '../lib' if -d '../lib'; } } use strict; use Test; BEGIN { plan tests => 8 } use XMLRPC::Lite; my($a, $s, $r, $serialized, $deserialized); { print "XML-RPC deserialization test(s)...\n"; $deserialized = XMLRPC::Deserializer->deserialize(' SOAP.Lite.Bug.Report ThisWorks ')->root; ok($deserialized->{params}->[0]->{This} eq 'Works'); $serialized = XMLRPC::Serializer->serialize({param1 => 'value1', param2 => undef, param3 => 0}); ok($serialized =~ m!param2!); ok($serialized =~ m!param30!); $deserialized = XMLRPC::Deserializer->deserialize($serialized)->root; ok($deserialized->{param2} eq ''); ok($deserialized->{param3} == 0); $serialized = XMLRPC::Serializer->method(a => {param1 => 'value1', param2 => undef, param3 => 'value3'}); ok($serialized =~ m!a(param1value1|param2|param3value3){3}!); $serialized = XMLRPC::Serializer->method(a => {param1 => 'value1'}); ok($serialized eq 'aparam1value1'); eval { XMLRPC::Serializer->serialize(XMLRPC::Data->type(base63 => 1)) }; ok($@ =~ /unsupported datatype/); } XMLRPC-Lite-0.717/t/26-xmlrpc.t000644 000765 000765 00000003734 12145307253 016103 0ustar00phredphred000000 000000 #!/bin/env perl # use diagnostics; BEGIN { unless(grep /blib/, @INC) { chdir 't' if -d 't'; unshift @INC, '../lib' if -d '../lib'; } } use strict; use Test; use XMLRPC::Lite; my($a, $s, $r); my $proxy = 'http://betty.userland.com/RPC2'; # ------------------------------------------------------ use SOAP::Test; $s = XMLRPC::Lite->proxy($proxy)->on_fault(sub{}); eval { $s->transport->timeout($SOAP::Test::TIMEOUT = $SOAP::Test::TIMEOUT) }; $r = $s->test_connection; unless (defined $r && defined $r->envelope) { print "1..0 # Skip: ", $s->transport->status, "\n"; exit; } # ------------------------------------------------------ #plan tests => 10; plan test => 6; { ok((XMLRPC::Lite -> proxy($proxy) -> call('examples.getStateStruct', {state1 => 12, state2 => 28}) -> result or '') eq 'Idaho,Nevada'); ok((XMLRPC::Lite -> proxy($proxy) -> call('examples.getStateName', 21) -> result or '') eq 'Massachusetts'); ok((XMLRPC::Lite -> proxy($proxy) -> call('examples.getStateNames', 21,22,23,24) -> result or '') =~ /Massachusetts\s+Michigan\s+Minnesota\s+Mississippi/); $s = XMLRPC::Lite -> proxy($proxy) -> call('examples.getStateList', [21,22]); ok(($s->result or '') eq 'Massachusetts,Michigan'); ok(! defined $s->fault); ok(! defined $s->faultcode); print "XMLRPC autodispatch and fault check test(s)...\n"; eval "use XMLRPC::Lite +autodispatch => proxy => '$proxy', ; 1" or die; $r = XMLRPC->getStateName(21); # Looks like this test requires saving away the result of the # last call - which introduces a memory leak (removed in 0.70_01) # Looks like we'll have to introduce different Fault handling... # # print "#TODO: fix fault handling ...\n"; last; $r = XMLRPC::Lite->self->call; ok(ref $r->fault eq 'HASH'); ok($r->fault->{faultString} =~ /Can't evaluate/); ok($r->faultstring =~ /Can't evaluate/); ok($r->faultcode == 7); } XMLRPC-Lite-0.717/t/37-mod_xmlrpc.t000644 000765 000765 00000000336 12145307253 016737 0ustar00phredphred000000 000000 #!/bin/env perl BEGIN { unless(grep /blib/, @INC) { chdir 't' if -d 't'; unshift @INC, '../lib' if -d '../lib'; } } use XMLRPC::Test; XMLRPC::Test::Server::run_for(shift || 'http://localhost/mod_xmlrpc'); XMLRPC-Lite-0.717/lib/Apache/000755 000765 000765 00000000000 12145606566 015652 5ustar00phredphred000000 000000 XMLRPC-Lite-0.717/lib/XMLRPC/000755 000765 000765 00000000000 12145606566 015476 5ustar00phredphred000000 000000 XMLRPC-Lite-0.717/lib/XMLRPC/Lite.pm000644 000765 000765 00000027241 12145307630 016725 0ustar00phredphred000000 000000 # ====================================================================== # # Copyright (C) 2000-2001 Paul Kulchenko (paulclinger@yahoo.com) # SOAP::Lite is free software; you can redistribute it # and/or modify it under the same terms as Perl itself. # # $Id$ # # ====================================================================== package XMLRPC::Lite; use SOAP::Lite; use strict; our $VERSION = 0.717; # ====================================================================== package XMLRPC::Constants; BEGIN { no strict 'refs'; for (qw( FAULT_CLIENT FAULT_SERVER HTTP_ON_SUCCESS_CODE HTTP_ON_FAULT_CODE DO_NOT_USE_XML_PARSER DO_NOT_USE_CHARSET DO_NOT_USE_LWP_LENGTH_HACK DO_NOT_CHECK_CONTENT_TYPE )) { *$_ = \${'SOAP::Constants::' . $_} } # XML-RPC spec requires content-type to be "text/xml" $XMLRPC::Constants::DO_NOT_USE_CHARSET = 1; } # ====================================================================== package XMLRPC::Data; @XMLRPC::Data::ISA = qw(SOAP::Data); # ====================================================================== package XMLRPC::Serializer; @XMLRPC::Serializer::ISA = qw(SOAP::Serializer); sub new { my $class = shift; return $class if ref $class; return $class->SUPER::new( typelookup => { base64 => [10, sub {$_[0] =~ /[^\x09\x0a\x0d\x20-\x7f]/}, 'as_base64'], int => [20, sub {$_[0] =~ /^[+-]?\d+$/}, 'as_int'], double => [30, sub {$_[0] =~ /^(-?(?:\d+(?:\.\d*)?|\.\d+)|([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?)$/}, 'as_double'], dateTime => [35, sub {$_[0] =~ /^\d{8}T\d\d:\d\d:\d\d$/}, 'as_dateTime'], string => [40, sub {1}, 'as_string'], }, attr => {}, namespaces => {}, @_, ); } sub envelope { my $self = shift; $self = $self->new() if not ref $self; # serves a method call if object my $type = shift; my $body; if ($type eq 'response') { # shift off method name to make XMLRPT happy my $method = shift or die "Unspecified method for XMLRPC call\n"; $body = XMLRPC::Data->name( methodResponse => \XMLRPC::Data->value( XMLRPC::Data->type(params => [@_]) ) ); } elsif ($type eq 'method') { # shift off method name to make XMLRPT happy my $method = shift or die "Unspecified method for XMLRPC call\n"; $body = XMLRPC::Data->name( methodCall => \XMLRPC::Data->value( XMLRPC::Data->type( methodName => UNIVERSAL::isa($method => 'XMLRPC::Data') ? $method->name : $method ), XMLRPC::Data->type(params => [@_]) )); } elsif ($type eq 'fault') { $body = XMLRPC::Data->name(methodResponse => \XMLRPC::Data->type(fault => {faultCode => $_[0], faultString => $_[1]}), ); } else { die "Wrong type of envelope ($type) for XMLRPC call\n"; } # SOAP::Lite keeps track of objects for XML aliasing and multiref # encoding. # Set/reset seen() hashref before/after encode_object avoids a # memory leak $self->seen({}); # initialize multiref table my $envelope = $self->xmlize($self->encode_object($body)); $self->seen({}); # delete multi-ref table - avoids a memory hole... return $envelope; } sub encode_object { my $self = shift; my @encoded = $self->SUPER::encode_object(@_); return $encoded[0]->[0] =~ /^(?:array|struct|i4|int|boolean|string|double|dateTime\.iso8601|base64)$/o ? ['value', {}, [@encoded]] : @encoded; } sub encode_scalar { my $self = shift; return ['value', {}] unless defined $_[0]; return $self->SUPER::encode_scalar(@_); } sub encode_array { my ($self, $array) = @_; return ['array', {}, [ ['data', {}, [ map {$self->encode_object($_)} @{ $array } ] ] ]]; } sub encode_hash { my ($self, $hash) = @_; return ['struct', {}, [ map { ['member', {}, [['name', {}, SOAP::Utils::encode_data($_)], $self->encode_object($hash->{$_})]] } keys %{ $hash } ]]; } sub as_methodName { my ($self, $value, $name, $type, $attr) = @_; return [ 'methodName', $attr, $value ]; } sub as_params { my ($self, $params, $name, $type, $attr) = @_; return ['params', $attr, [ map { ['param', {}, [ $self->encode_object($_) ] ] } @$params ]]; } sub as_fault { my ($self, $fault) = @_; return ['fault', {}, [ $self->encode_object($fault) ] ]; } sub BEGIN { no strict 'refs'; for my $type (qw(double i4 int)) { my $method = 'as_' . $type; *$method = sub { my($self, $value) = @_; return [ $type, {}, $value ]; } } } sub as_base64 { my ($self, $value) = @_; require MIME::Base64; return ['base64', {}, MIME::Base64::encode_base64($value,'')]; } sub as_string { my ($self, $value) = @_; return ['string', {}, SOAP::Utils::encode_data($value)]; } sub as_dateTime { my ($self, $value) = @_; return ['dateTime.iso8601', {}, $value]; } sub as_boolean { my ($self, $value) = @_; return ['boolean', {}, $value ? 1 : 0]; } sub typecast { my ($self, $value, $name, $type, $attr) = @_; die "Wrong/unsupported datatype '$type' specified\n" if defined $type; $self->SUPER::typecast(@_); } # ====================================================================== package XMLRPC::SOM; @XMLRPC::SOM::ISA = qw(SOAP::SOM); sub BEGIN { no strict 'refs'; my %path = ( root => '/', envelope => '/[1]', method => '/methodCall/methodName', fault => '/methodResponse/fault', ); for my $method (keys %path) { *$method = sub { my $self = shift; ref $self or return $path{$method}; Carp::croak "Method '$method' is readonly and doesn't accept any parameters" if @_; $self->valueof($path{$method}); }; } my %fault = ( faultcode => 'faultCode', faultstring => 'faultString', ); for my $method (keys %fault) { *$method = sub { my $self = shift; ref $self or Carp::croak "Method '$method' doesn't have shortcut"; Carp::croak "Method '$method' is readonly and doesn't accept any parameters" if @_; defined $self->fault ? $self->fault->{$fault{$method}} : undef; }; } my %results = ( result => '/methodResponse/params/[1]', paramsin => '/methodCall/params/param', paramsall => '/methodResponse/params/param', ); for my $method (keys %results) { *$method = sub { my $self = shift; ref $self or return $results{$method}; Carp::croak "Method '$method' is readonly and doesn't accept any parameters" if @_; defined $self->fault() ? undef : $self->valueof($results{$method}); }; } } # ====================================================================== package XMLRPC::Deserializer; @XMLRPC::Deserializer::ISA = qw(SOAP::Deserializer); BEGIN { no strict 'refs'; for my $method (qw(o_child o_qname o_chars)) { # import from SOAP::Utils *$method = \&{'SOAP::Utils::'.$method}; } } sub deserialize { # just deserialize with SOAP::Lite's deserializer, and re-bless as # XMLRPC::SOM bless shift->SUPER::deserialize(@_) => 'XMLRPC::SOM'; } sub decode_value { my $self = shift; my $ref = shift; my($name, $attrs, $children, $value) = @$ref; if ($name eq 'value') { $children ? scalar(($self->decode_object($children->[0]))[1]) : $value; } elsif ($name eq 'array') { return [map {scalar(($self->decode_object($_))[1])} @{o_child($children->[0]) || []}]; } elsif ($name eq 'struct') { return { map { my %hash = map { o_qname($_) => $_ } @{o_child($_) || []}; # v----- scalar is required here, because 5.005 evaluates 'undef' in list context as empty array (o_chars($hash{name}) => scalar(($self->decode_object($hash{value}))[1])); } @{$children || []}}; } elsif ($name eq 'base64') { require MIME::Base64; MIME::Base64::decode_base64($value); } elsif ($name =~ /^(?:int|i4|boolean|string|double|dateTime\.iso8601|methodName)$/) { return $value; } elsif ($name =~ /^(?:params)$/) { return [map {scalar(($self->decode_object($_))[1])} @{$children || []}]; } elsif ($name =~ /^(?:methodResponse|methodCall)$/) { return +{map {$self->decode_object($_)} @{$children || []}}; } elsif ($name =~ /^(?:param|fault)$/) { return scalar(($self->decode_object($children->[0]))[1]); } elsif ($name =~ /^(?:nil)$/) { return undef; } else { die "wrong element '$name'\n"; } } # ====================================================================== package XMLRPC::Server; @XMLRPC::Server::ISA = qw(SOAP::Server); sub initialize { return ( deserializer => XMLRPC::Deserializer->new, serializer => XMLRPC::Serializer->new, on_action => sub {}, on_dispatch => sub { return map {s!\.!/!g; $_} shift->method =~ /^(?:(.*)\.)?(\w+)$/ }, ); } # ====================================================================== package XMLRPC::Server::Parameters; @XMLRPC::Server::Parameters::ISA = qw(SOAP::Server::Parameters); # ====================================================================== package XMLRPC; @XMLRPC::ISA = qw(SOAP); # ====================================================================== package XMLRPC::Lite; @XMLRPC::Lite::ISA = qw(SOAP::Lite); sub new { my $class = shift; return $class if ref $class; return $class->SUPER::new( serializer => XMLRPC::Serializer->new, deserializer => XMLRPC::Deserializer->new, on_action => sub {return}, default_ns => 'http://unspecified/', @_ ); } # ====================================================================== 1; __END__ =head1 NAME XMLRPC::Lite - client and server implementation of XML-RPC protocol =head1 SYNOPSIS =over 4 =item Client use XMLRPC::Lite; print XMLRPC::Lite -> proxy('http://betty.userland.com/RPC2') -> call('examples.getStateStruct', {state1 => 12, state2 => 28}) -> result; =item CGI server use XMLRPC::Transport::HTTP; my $server = XMLRPC::Transport::HTTP::CGI -> dispatch_to('methodName') -> handle ; =item Daemon server use XMLRPC::Transport::HTTP; my $daemon = XMLRPC::Transport::HTTP::Daemon -> new (LocalPort => 80) -> dispatch_to('methodName') ; print "Contact to XMLRPC server at ", $daemon->url, "\n"; $daemon->handle; =back =head1 DESCRIPTION XMLRPC::Lite is a Perl modules which provides a simple nterface to the XML-RPC protocol both on client and server side. Based on SOAP::Lite module, it gives you access to all features and transports available in that module. See F for client examples and F for server implementations. =head1 DEPENDENCIES SOAP::Lite =head1 SEE ALSO SOAP::Lite =head1 CREDITS The B standard is Copyright (c) 1998-2001, UserLand Software, Inc. See for more information about the B specification. =head1 COPYRIGHT Copyright (C) 2000-2001 Paul Kulchenko. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR Paul Kulchenko (paulclinger@yahoo.com) =cut XMLRPC-Lite-0.717/lib/XMLRPC/Test.pm000644 000765 000765 00000011453 12145307640 016746 0ustar00phredphred000000 000000 # ====================================================================== # # Copyright (C) 2000-2001 Paul Kulchenko (paulclinger@yahoo.com) # SOAP::Lite is free software; you can redistribute it # and/or modify it under the same terms as Perl itself. # # $Id$ # # ====================================================================== package XMLRPC::Test; use 5.004; use vars qw($VERSION $TIMEOUT); our $VERSION = 0.717; $TIMEOUT = 5; # ====================================================================== package My::PingPong; # we'll use this package in our tests sub new { my $self = shift; my $class = ref($self) || $self; bless {_num=>shift} => $class; } sub next { my $self = shift; $self->{_num}++; } sub value { my $self = shift; $self->{_num}; } # ====================================================================== package XMLRPC::Test::Server; use strict; use Test; use XMLRPC::Lite; sub run_for { my $proxy = shift or die "Proxy/endpoint is not specified"; # ------------------------------------------------------ my $s = XMLRPC::Lite->proxy($proxy)->on_fault(sub{}); eval { $s->transport->timeout($XMLRPC::Test::TIMEOUT) }; my $r = $s->test_connection; unless (defined $r && defined $r->envelope) { print "1..0 # Skip: ", $s->transport->status, "\n"; exit; } # ------------------------------------------------------ plan tests => 17; eval q!use XMLRPC::Lite on_fault => sub{ref $_[1] ? $_[1] : new XMLRPC::SOM}; 1! or die; print "Perl XMLRPC server test(s)...\n"; $s = XMLRPC::Lite -> proxy($proxy) ; ok($s->call('My.Examples.getStateName', 1)->result eq 'Alabama'); ok($s->call('My.Examples.getStateNames', 1,4,6,13)->result =~ /^Alabama\s+Arkansas\s+Colorado\s+Illinois\s*$/); $r = $s->call('My.Examples.getStateList', [1,2,3,4])->result; ok(ref $r && $r->[0] eq 'Alabama'); $r = $s->call('My.Examples.getStateStruct', {item1 => 1, item2 => 4})->result; ok(ref $r && $r->{item2} eq 'Arkansas'); print "dispatch_from test(s)...\n"; eval "use XMLRPC::Lite dispatch_from => ['A', 'B'], proxy => '$proxy', ; 1" or die; eval { C->c }; ok($@ =~ /Can't locate object method "c"/); print "Object autobinding and XMLRPC:: prefix test(s)...\n"; eval "use XMLRPC::Lite +autodispatch => proxy => '$proxy'; 1" or die; ok(XMLRPC::Lite->autodispatched); # forget everything XMLRPC::Lite->self(undef); { my $on_fault_was_called = 0; print "Die in server method test(s)...\n"; my $s = XMLRPC::Lite -> proxy($proxy) -> on_fault(sub{$on_fault_was_called++;return}) ; ok($s->call('My.Parameters.die_simply')->faultstring =~ /Something bad/); ok($on_fault_was_called > 0); # get Fault as hash of subelements my $fault = $s->call('My.Parameters.die_with_fault'); ok($fault->faultcode =~ 'Server\.Custom'); ok($fault->faultstring eq 'Died in server method'); } print "Number of parameters test(s)...\n"; $s = XMLRPC::Lite -> proxy($proxy) ; { my @all = $s->call('My.Parameters.echo')->paramsall; ok(@all == 0) } { my @all = $s->call('My.Parameters.echo', 1)->paramsall; ok(@all == 1) } { my @all = $s->call('My.Parameters.echo', (1) x 10)->paramsall; ok(@all == 10) } print "Memory refresh test(s)...\n"; # Funny test. # Let's forget about ALL settings we did before with 'use XMLRPC::Lite...' XMLRPC::Lite->self(undef); ok(!defined XMLRPC::Lite->self); eval "use XMLRPC::Lite proxy => '$proxy'; 1" or die; print "Global settings test(s)...\n"; $s = new XMLRPC::Lite; ok($s->call('My.Examples.getStateName', 1)->result eq 'Alabama'); SOAP::Trace->import(transport => sub {$_[0]->content_type('something/wrong') if UNIVERSAL::isa($_[0] => 'HTTP::Request')} ); if ($proxy =~ /^tcp:/) { skip('No Content-Type checks for tcp: protocol on server side' => undef); } else { ok($s->call('My.Examples.getStateName', 1)->faultstring =~ /Content-Type must be/); } # check status for fault messages if ($proxy =~ /^http/) { ok($s->transport->status =~ /^200/); } else { skip('No Status checks for non http protocols on server side' => undef); } } # ====================================================================== 1; __END__ =head1 NAME XMLRPC::Test - Test framework for XMLRPC::Lite =head1 SYNOPSIS use XMLRPC::Test; XMLRPC::Test::Server::run_for('http://localhost/cgi-bin/XMLRPC.cgi'); =head1 DESCRIPTION XMLRPC::Test provides simple framework for testing server implementations. Specify your address (endpoint) and run provided tests against your server. See t/1*.t for examples. =head1 COPYRIGHT Copyright (C) 2000-2001 Paul Kulchenko. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR Paul Kulchenko (paulclinger@yahoo.com) =cut XMLRPC-Lite-0.717/lib/XMLRPC/Transport/000755 000765 000765 00000000000 12145606566 017472 5ustar00phredphred000000 000000 XMLRPC-Lite-0.717/lib/XMLRPC/Transport/HTTP.pm000644 000765 000765 00000013455 12145307653 020612 0ustar00phredphred000000 000000 # ====================================================================== # # Copyright (C) 2000-2001 Paul Kulchenko (paulclinger@yahoo.com) # SOAP::Lite is free software; you can redistribute it # and/or modify it under the same terms as Perl itself. # # $Id$ # # ====================================================================== package XMLRPC::Transport::HTTP; use strict; our $VERSION = 0.717; use XMLRPC::Lite; use SOAP::Transport::HTTP; # ====================================================================== package XMLRPC::Transport::HTTP::CGI; @XMLRPC::Transport::HTTP::CGI::ISA = qw(SOAP::Transport::HTTP::CGI); sub initialize; *initialize = \&XMLRPC::Server::initialize; sub make_fault { local $SOAP::Constants::HTTP_ON_FAULT_CODE = 200; shift->SUPER::make_fault(@_); } sub make_response { local $SOAP::Constants::DO_NOT_USE_CHARSET = 1; shift->SUPER::make_response(@_); } # ====================================================================== package XMLRPC::Transport::HTTP::Daemon; @XMLRPC::Transport::HTTP::Daemon::ISA = qw(SOAP::Transport::HTTP::Daemon); sub initialize; *initialize = \&XMLRPC::Server::initialize; sub make_fault; *make_fault = \&XMLRPC::Transport::HTTP::CGI::make_fault; sub make_response; *make_response = \&XMLRPC::Transport::HTTP::CGI::make_response; # ====================================================================== package XMLRPC::Transport::HTTP::Apache; @XMLRPC::Transport::HTTP::Apache::ISA = qw(SOAP::Transport::HTTP::Apache); sub initialize; *initialize = \&XMLRPC::Server::initialize; sub make_fault; *make_fault = \&XMLRPC::Transport::HTTP::CGI::make_fault; sub make_response; *make_response = \&XMLRPC::Transport::HTTP::CGI::make_response; # ====================================================================== 1; __END__ =head1 NAME XMLRPC::Transport::HTTP - Server/Client side HTTP support for XMLRPC::Lite =head1 SYNOPSIS =over 4 =item Client use XMLRPC::Lite proxy => 'http://localhost/', # proxy => 'http://localhost/cgi-bin/xmlrpc.cgi', # local CGI server # proxy => 'http://localhost/', # local daemon server # proxy => 'http://login:password@localhost/cgi-bin/xmlrpc.cgi', # local CGI server with authentication ; print getStateName(1); =item CGI server use XMLRPC::Transport::HTTP; my $server = XMLRPC::Transport::HTTP::CGI -> dispatch_to('methodName') -> handle ; =item Daemon server use XMLRPC::Transport::HTTP; my $daemon = XMLRPC::Transport::HTTP::Daemon -> new (LocalPort => 80) -> dispatch_to('methodName') ; print "Contact to XMLRPC server at ", $daemon->url, "\n"; $daemon->handle; =back =head1 DESCRIPTION This class encapsulates all HTTP related logic for a XMLRPC server, independent of what web server it's attached to. If you want to use this class you should follow simple guideline mentioned above. =head2 PROXY SETTINGS You can use any proxy setting you use with LWP::UserAgent modules: XMLRPC::Lite->proxy('http://endpoint.server/', proxy => ['http' => 'http://my.proxy.server']); or $xmlrpc->transport->proxy('http' => 'http://my.proxy.server'); should specify proxy server for you. And if you use C and C for proxy authorization SOAP::Lite should know how to handle it properly. =head2 COOKIE-BASED AUTHENTICATION use HTTP::Cookies; my $cookies = HTTP::Cookies->new(ignore_discard => 1); # you may also add 'file' if you want to keep them between sessions my $xmlrpc = XMLRPC::Lite->proxy('http://localhost/'); $xmlrpc->transport->cookie_jar($cookies); Cookies will be taken from response and provided for request. You may always add another cookie (or extract what you need after response) with HTTP::Cookies interface. You may also do it in one line: $xmlrpc->proxy('http://localhost/', cookie_jar => HTTP::Cookies->new(ignore_discard => 1)); =head2 COMPRESSION XMLRPC::Lite provides you option for enabling compression on wire (for HTTP transport only). Both server and client should support this capability, but this logic should be absolutely transparent for your application. Server will respond with encoded message only if client can accept it (client sends Accept-Encoding with 'deflate' or '*' values) and client has fallback logic, so if server doesn't understand specified encoding (Content-Encoding: deflate) and returns proper error code (415 NOT ACCEPTABLE) client will repeat the same request not encoded and will store this server in per-session cache, so all other requests will go there without encoding. Having options on client and server side that let you specify threshold for compression you can safely enable this feature on both client and server side. Compression will be enabled on client side IF: threshold is specified AND size of current message is bigger than threshold AND module Compress::Zlib is available. Client will send header 'Accept-Encoding' with value 'deflate' if threshold is specified AND module Compress::Zlib is available. Server will accept compressed message if module Compress::Zlib is available, and will respond with compressed message ONLY IF: threshold is specified AND size of current message is bigger than threshold AND module Compress::Zlib is available AND header 'Accept-Encoding' is presented in request. =head1 DEPENDENCIES Crypt::SSLeay for HTTPS/SSL HTTP::Daemon for XMLRPC::Transport::HTTP::Daemon Apache, Apache::Constants for XMLRPC::Transport::HTTP::Apache =head1 SEE ALSO See ::CGI, ::Daemon and ::Apache for implementation details. See examples/XMLRPC/* for examples. =head1 COPYRIGHT Copyright (C) 2000-2001 Paul Kulchenko. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR Paul Kulchenko (paulclinger@yahoo.com) =cut XMLRPC-Lite-0.717/lib/XMLRPC/Transport/POP3.pm000644 000765 000765 00000003714 12145307702 020544 0ustar00phredphred000000 000000 # ====================================================================== # # Copyright (C) 2000-2001 Paul Kulchenko (paulclinger@yahoo.com) # SOAP::Lite is free software; you can redistribute it # and/or modify it under the same terms as Perl itself. # # $Id$ # # ====================================================================== package XMLRPC::Transport::POP3; use strict; our $VERSION = 0.717; use XMLRPC::Lite; use SOAP::Transport::POP3; # ====================================================================== package XMLRPC::Transport::POP3::Server; @XMLRPC::Transport::POP3::Server::ISA = qw(SOAP::Transport::POP3::Server); sub initialize; *initialize = \&XMLRPC::Server::initialize; # ====================================================================== 1; __END__ =head1 NAME XMLRPC::Transport::POP3 - Server side POP3 support for XMLRPC::Lite =head1 SYNOPSIS use XMLRPC::Transport::POP3; my $server = XMLRPC::Transport::POP3::Server -> new('pop://pop.mail.server') # if you want to have all in one place # -> new('pop://user:password@pop.mail.server') # or, if you have server that supports MD5 protected passwords # -> new('pop://user:password;AUTH=+APOP@pop.mail.server') # specify path to My/Examples.pm here -> dispatch_to('/Your/Path/To/Deployed/Modules', 'Module::Name', 'Module::method'); # you don't need to use next line if you specified your password in new() $server->login('user' => 'password') or die "Can't authenticate to POP3 server\n"; # handle will return number of processed mails # you can organize loop if you want do { $server->handle } while sleep 10; # you may also call $server->quit explicitly to purge deleted messages =head1 DESCRIPTION =head1 COPYRIGHT Copyright (C) 2000-2001 Paul Kulchenko. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR Paul Kulchenko (paulclinger@yahoo.com) =cut XMLRPC-Lite-0.717/lib/XMLRPC/Transport/TCP.pm000644 000765 000765 00000003107 12145307711 020445 0ustar00phredphred000000 000000 # ====================================================================== # # Copyright (C) 2000-2001 Paul Kulchenko (paulclinger@yahoo.com) # SOAP::Lite is free software; you can redistribute it # and/or modify it under the same terms as Perl itself. # # $Id$ # # ====================================================================== package XMLRPC::Transport::TCP; use strict; our $VERSION = 0.717; use XMLRPC::Lite; use SOAP::Transport::TCP; # ====================================================================== package XMLRPC::Transport::TCP::Server; @XMLRPC::Transport::TCP::Server::ISA = qw(SOAP::Transport::TCP::Server); sub initialize; *initialize = \&XMLRPC::Server::initialize; # ====================================================================== 1; __END__ =head1 NAME XMLRPC::Transport::TCP - Server/Client side TCP support for XMLRPC::Lite =head1 SYNOPSIS use XMLRPC::Transport::TCP; my $daemon = XMLRPC::Transport::TCP::Server -> new (LocalAddr => 'localhost', LocalPort => 82, Listen => 5, Reuse => 1) -> objects_by_reference(qw(My::PersistentIterator My::SessionIterator My::Chat)) -> dispatch_to('/Your/Path/To/Deployed/Modules', 'Module::Name', 'Module::method'); print "Contact to XMLRPC server at ", join(':', $daemon->sockhost, $daemon->sockport), "\n"; $daemon->handle; =head1 DESCRIPTION =head1 COPYRIGHT Copyright (C) 2000-2001 Paul Kulchenko. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR Paul Kulchenko (paulclinger@yahoo.com) =cut XMLRPC-Lite-0.717/lib/Apache/XMLRPC/000755 000765 000765 00000000000 12145606566 016657 5ustar00phredphred000000 000000 XMLRPC-Lite-0.717/lib/Apache/XMLRPC/Lite.pm000644 000765 000765 00000007423 12145307615 020111 0ustar00phredphred000000 000000 # ====================================================================== # # Copyright (C) 2000-2001 Paul Kulchenko (paulclinger@yahoo.com) # SOAP::Lite is free software; you can redistribute it # and/or modify it under the same terms as Perl itself. # # $Id$ # # ====================================================================== package Apache::XMLRPC::Lite; use strict; use vars qw(@ISA $VERSION); use XMLRPC::Transport::HTTP; @ISA = qw(XMLRPC::Transport::HTTP::Apache); our $VERSION = 0.717; my $server = __PACKAGE__->new; sub server { return $server; } sub handler { $server->configure(@_); $server->SUPER::handler(@_); } # ====================================================================== 1; __END__ =head1 NAME Apache::XMLRPC::Lite - mod_perl-based XML-RPC server with minimum configuration =head1 SYNOPSIS =over 4 =item httpd.conf (Location), directory-based access SetHandler perl-script PerlHandler Apache::XMLRPC::Lite PerlSetVar dispatch_to "/Your/Path/To/Deployed/Modules, Module::Name, Module::method" PerlSetVar options "compress_threshold => 10000" =item httpd.conf (Files), file-based access SetHandler perl-script PerlHandler Apache::XMLRPC::Lite PerlSetVar dispatch_to "/Your/Path/To/Deployed/Modules, Module::Name, Module::method" PerlSetVar options "compress_threshold => 10000" =item .htaccess, directory-based access SetHandler perl-script PerlHandler Apache::XMLRPC::Lite PerlSetVar dispatch_to "/Your/Path/To/Deployed/Modules, Module::Name, Module::method" PerlSetVar options "compress_threshold => 10000" =back =head1 DESCRIPTION This Apache Perl module provides the ability to add support for XML-RPC protocol with easy configuration (either in .conf or in .htaccess file). This functionality should give you lightweight option for hosting SOAP services and greatly simplify configuration aspects. This module inherites functionality from XMLRPC::Transport::HTTP::Apache component of XMLRPC::Lite module. =head1 CONFIGURATION The module can be placed in , , , directives in main server configuration areas or directly in .htaccess file. All parameters should be quoted and can be separated with commas or spaces for lists ("a, b, c") and with 'wide arrows' and commas for hash parameters ("key1 => value1, key2 => value2"). All options that you can find in XMLRPC::Transport::HTTP::Apache component are available for configuration. Here is the description of most important ones. =over 4 =item dispatch_to (LIST) Specifies path to directory that contains Perl modules you'd like to give access to, or just list of modules (for preloaded modules). PerlSetVar dispatch_to "/Your/Path/To/Deployed/Modules, Module::Name, Module::method" =item options (HASH) Specifies list of options for your module, for example threshold for compression. Future versions will support more options. See XMLRPC::Transport::HTTP documentation for other options. PerlSetVar options "compress_threshold => 10000" =back =head1 METHODS/SUBROUTINES =head2 server my $server = Apache::XMLRPC::Lite->server(); Returns the server object. Useful if you need to manipulate the server object from your code. =head2 handle Request handler. Called by apache. =head1 DEPENDENCIES XMLRPC::Lite mod_perl =head1 SEE ALSO XMLRPC::Transport::HTTP::Apache for implementation details, XMLRPC::Lite for general information, and F for .htaccess example =head1 COPYRIGHT Copyright (C) 2000-2001 Paul Kulchenko. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR Paul Kulchenko (paulclinger@yahoo.com) =cut