[Catalyst-commits] r7168 - in Catalyst-Controller-SOAP/1.0/trunk: .
lib/Catalyst/Action lib/Catalyst/Action/SOAP
lib/Catalyst/Controller t t/lib t/lib/TestApp
t/lib/TestApp/Controller
ruoso at dev.catalyst.perl.org
ruoso at dev.catalyst.perl.org
Tue Nov 27 10:53:41 GMT 2007
Author: ruoso
Date: 2007-11-27 10:53:41 +0000 (Tue, 27 Nov 2007)
New Revision: 7168
Added:
Catalyst-Controller-SOAP/1.0/trunk/META.yml
Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/HTTPGet.pm
Catalyst-Controller-SOAP/1.0/trunk/t/lib/
Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp.pm
Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp/
Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp/Controller/
Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp/Controller/Root.pm
Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp/Controller/WS.pm
Modified:
Catalyst-Controller-SOAP/1.0/trunk/MANIFEST
Catalyst-Controller-SOAP/1.0/trunk/Makefile.PL
Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP.pm
Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm
Catalyst-Controller-SOAP/1.0/trunk/t/Catalyst-Controller-SOAP.t
Log:
[C-C-SOAP] [git2svn] Wed Nov 14 14:22:14 2007 +0000 -- fixing the attribute parsing method. HTTPGet working, POST test failing because the post data is not reaching the destination...
Modified: Catalyst-Controller-SOAP/1.0/trunk/MANIFEST
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/MANIFEST 2007-11-27 10:51:20 UTC (rev 7167)
+++ Catalyst-Controller-SOAP/1.0/trunk/MANIFEST 2007-11-27 10:53:41 UTC (rev 7168)
@@ -1,10 +1,17 @@
Changes
Makefile.PL
MANIFEST
-ppport.h
+META.yml
README
-SOAP.xs
t/Catalyst-Controller-SOAP.t
-fallback/const-c.inc
-fallback/const-xs.inc
+t/lib/TestApp/Controller/WS.pm
+t/lib/TestApp/Controller/Root.pm
+t/lib/TestApp.pm
+lib/Catalyst/Action/SOAP.pm
+lib/Catalyst/Action/SOAP/DocumentLiteral.pm
+lib/Catalyst/Action/SOAP/HTTPGet.pm
+lib/Catalyst/Action/SOAP/RPCEndpoint.pm
+lib/Catalyst/Action/SOAP/RPCLiteral.pm
+lib/Catalyst/Action/SOAP/RPCEncoded.pm
lib/Catalyst/Controller/SOAP.pm
+lib/Catalyst/Controller/SOAP/RPC.pm
Added: Catalyst-Controller-SOAP/1.0/trunk/META.yml
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/META.yml (rev 0)
+++ Catalyst-Controller-SOAP/1.0/trunk/META.yml 2007-11-27 10:53:41 UTC (rev 7168)
@@ -0,0 +1,16 @@
+--- #YAML:1.0
+name: Catalyst-Controller-SOAP
+abstract: Add SOAP features to the Catalyst Framework
+version: 0.0.1
+author:
+ - Daniel Ruoso <daniel.ruoso at verticalone.pt>
+license: perl
+distribution_type: module
+requires:
+ XML::LibXML: 0
+ Catalyst::Controller: 5.7000
+meta-spec:
+ version: 1.3
+ url: http://module-build.sourceforge.net/META-spec-v1.3.html
+resources:
+ repository: http://people.debian.org/~ruoso/Catalyst-Controller-SOAP/
Modified: Catalyst-Controller-SOAP/1.0/trunk/Makefile.PL
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/Makefile.PL 2007-11-27 10:51:20 UTC (rev 7167)
+++ Catalyst-Controller-SOAP/1.0/trunk/Makefile.PL 2007-11-27 10:53:41 UTC (rev 7168)
@@ -5,36 +5,8 @@
WriteMakefile(
NAME => 'Catalyst::Controller::SOAP',
VERSION_FROM => 'lib/Catalyst/Controller/SOAP.pm', # finds $VERSION
- PREREQ_PM => {}, # e.g., Module::Name => 1.1
+ PREREQ_PM => { Catalyst::Controller => 5.7000, XML::LibXML => 0}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/Catalyst/Controller/SOAP.pm', # retrieve abstract from module
- AUTHOR => 'Daniel Ruoso <ruoso@>') : ()),
- LIBS => [''], # e.g., '-lm'
- DEFINE => '', # e.g., '-DHAVE_SOMETHING'
- INC => '-I.', # e.g., '-I. -I/usr/include/other'
- # Un-comment this if you add C files to link with later:
- # OBJECT => '$(O_FILES)', # link all the C files too
+ AUTHOR => 'Daniel Ruoso <daniel.ruoso at verticalone.pt>') : ()),
);
-if (eval {require ExtUtils::Constant; 1}) {
- # If you edit these definitions to change the constants used by this module,
- # you will need to use the generated const-c.inc and const-xs.inc
- # files to replace their "fallback" counterparts before distributing your
- # changes.
- my @names = (qw());
- ExtUtils::Constant::WriteConstants(
- NAME => 'Catalyst::Controller::SOAP',
- NAMES => \@names,
- DEFAULT_TYPE => 'IV',
- C_FILE => 'const-c.inc',
- XS_FILE => 'const-xs.inc',
- );
-
-}
-else {
- use File::Copy;
- use File::Spec;
- foreach my $file ('const-c.inc', 'const-xs.inc') {
- my $fallback = File::Spec->catfile('fallback', $file);
- copy ($fallback, $file) or die "Can't copy $fallback to $file: $!";
- }
-}
Added: Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/HTTPGet.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/HTTPGet.pm (rev 0)
+++ Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/HTTPGet.pm 2007-11-27 10:53:41 UTC (rev 7168)
@@ -0,0 +1,51 @@
+{ package Catalyst::Action::SOAP::HTTPGet;
+
+ use base qw/Catalyst::Action::SOAP/;
+
+ sub execute {
+ my $self = shift;
+ my ( $controller, $c ) = @_;
+ $self->prepare_soap_helper($c);
+ $self->NEXT::execute(@_);
+ }
+};
+
+1;
+
+__END__
+
+=head1 NAME
+
+Catalyst::Action::SOAP::HTTPGet - HTTP Get service
+
+=head1 SYNOPSIS
+
+ # not used directly.
+
+=head1 DESCRIPTION
+
+This actually is here just to help delivering services that are
+invoked by simple http get requests, as defined in the SOAP spec. It
+won't do much, except for preparing the $c->stash->{soap} variable, so
+the returns can be implemented.
+
+=head1 TODO
+
+There is not much to be done here.
+
+=head1 AUTHORS
+
+Daniel Ruoso <daniel.ruoso at verticalone.pt>
+
+=head1 BUG REPORTS
+
+Please submit all bugs regarding C<Catalyst::Controller::SOAP> to
+C<bug-catalyst-controller-soap at rt.cpan.org>
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
Modified: Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP.pm 2007-11-27 10:51:20 UTC (rev 7167)
+++ Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP.pm 2007-11-27 10:53:41 UTC (rev 7168)
@@ -1,14 +1,14 @@
{ package Catalyst::Action::SOAP;
use base qw/Catalyst::Action/;
- use XML::DOM::XPath;
+ use XML::LibXML;
__PACKAGE__->mk_accessors(qw/xml_parser/);
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
- $self->xml_parser(XML::DOM::Parser->new());
+ $self->xml_parser(XML::LibXML->new());
return $self;
}
@@ -24,7 +24,7 @@
my $xml_str = $c->req->body;
eval {
$c->stash->{soap}->envelope($xml_str);
- $c->stash->{soap}->parsed_envelope($self->xml_parser->parse($xml_str));
+ $c->stash->{soap}->parsed_envelope($self->xml_parser->parse_string($xml_str));
};
if ($@) {
$c->stash->{soap}->fault({ code => 'env:Sender', reason => 'Bad XML Message', detail => $@});
Modified: Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm 2007-11-27 10:51:20 UTC (rev 7167)
+++ Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm 2007-11-27 10:53:41 UTC (rev 7168)
@@ -7,10 +7,10 @@
use constant NS_SOAP_ENV => "http://www.w3.org/2003/05/soap-envelope";
our $VERSION = '0.0.1';
- sub _parse_SOAP_Attr {
+ sub _parse_SOAP_attr {
my ($self, $c, $name, $value) = @_;
- my $actionclass = $value =~ /^+/ ? $value :
- 'SOAP::'.$value;
+ my $actionclass = ($value =~ /^\+/ ? $value :
+ 'Catalyst::Action::SOAP::'.$value);
(
ActionClass => $actionclass,
)
@@ -18,11 +18,11 @@
# this is implemented as to respond a SOAP message according to
# what has been sent to $c->stash->{soap}
- sub End : Private {
+ sub end : Private {
my ($self, $c) = (shift, shift);
my $soap = $c->stash->{soap};
- return $self->NEXT::End($c, @_) unless $soap;
+ return $self->NEXT::end($c, @_) unless $soap;
my $response = XML::LibXML->createDocument();
@@ -47,7 +47,7 @@
(NS_SOAP_ENV, "Code");
$fault->appendChild($code);
- $self->_generate_Fault_Code($response,$code,$soap->{code});
+ $self->_generate_Fault_Code($response,$code,$soap->fault->{code});
if ($soap->fault->{reason}) {
my $reason = $response->createElementNS
@@ -82,7 +82,7 @@
}
sub _generate_Fault_Code {
- my ($self, $document, $codenode, $codevalue) = @_;
+ my ($self, $document, $codenode, $codeValue) = @_;
my $value = $document->createElementNS
(NS_SOAP_ENV, "Value");
@@ -99,13 +99,14 @@
}
}
+
};
{ package Catalyst::Controller::SOAP::Helper;
use base qw(Class::Accessor::Fast);
- __PACKAGE__->mk_accessors(qw{envelope parsed_envelope arguments error
+ __PACKAGE__->mk_accessors(qw{envelope parsed_envelope arguments fault
encoded_return literal_return
literal_string_return string_return});
@@ -118,7 +119,7 @@
=head1 NAME
-Catalyst::Controller::SOAP -- Catalyst SOAP Controller
+Catalyst::Controller::SOAP - Catalyst SOAP Controller
=head1 SYNOPSIS
@@ -149,15 +150,17 @@
# dispatched. This code won't be executed at all.
sub index : SOAP('RPCEndpoint') {}
+=head1 ABSTACT
+
+Implements SOAP serving support in Catalyst.
+
=head1 DESCRIPTION
SOAP Controller for Catalyst which we tried to make compatible with
-the way Catalyst works with URLS.
+the way Catalyst works with URLS.It is important to notice that this
+controller declares by default an index operation which will dispatch
+the RPC operations under this class.
-It is important to notice that this controller declares by default an
-index operation which will dispatch the RPC operations under this
-class.
-
=back
=head1 ATTRIBUTES
Modified: Catalyst-Controller-SOAP/1.0/trunk/t/Catalyst-Controller-SOAP.t
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/Catalyst-Controller-SOAP.t 2007-11-27 10:51:20 UTC (rev 7167)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/Catalyst-Controller-SOAP.t 2007-11-27 10:53:41 UTC (rev 7168)
@@ -1,15 +1,38 @@
-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl Catalyst-Controller-SOAP.t'
-
-#########################
-
-# change 'tests => 1' to 'tests => last_test_to_print';
-
-use Test::More tests => 1;
+use Test::More tests => 3;
BEGIN { use_ok('Catalyst::Controller::SOAP') };
+use Catalyst::Action::SOAP::DocumentLiteral;
+use lib qw(lib t/lib);
+use IO::Scalar;
+use File::Temp;
+use Catalyst::Test 'TestApp';
+use Encode;
-#########################
+my $message = <<SOAP;
+<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope">
+ <Body>World</Body>
+</Envelope>
+SOAP
+my $fh = tmpfile();
+print {$fh} $message;
+seek $fh, 0, 'SEEK_SET';
+my $response = post_soap('/ws/hello',$message);
+my $response_content = $response->content;
+ok($response_content =~ /Hello World/, 'Document Literal POST!');
-# Insert your test code below, the Test::More module is use()ed here so read
-# its man page ( perldoc Test::More ) for help writing this test script.
+$response_content = get('/ws/foo?who=World');
+ok($response_content =~ /Hello World/, 'HTTP Get!');
+sub post_soap {
+ my $uri = shift;
+ my $xml_content = shift;
+ require HTTP::Request::AsCGI;
+ my $request = Catalyst::Utils::request( $uri );
+ $request->method('POST');
+ $request->content_type('application/soap+xml');
+ $request->content_encoding('utf8');
+ $request->content(encode_utf8($xml_content));
+ my $cgi = HTTP::Request::AsCGI->new( $request, %ENV )->setup;
+ $cgi->stdin($fh);
+ TestApp->handle_request;
+ return $cgi->restore->response;
+}
Added: Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp/Controller/Root.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp/Controller/Root.pm (rev 0)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp/Controller/Root.pm 2007-11-27 10:53:41 UTC (rev 7168)
@@ -0,0 +1,16 @@
+package TestApp::Controller::Root;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+__PACKAGE__->config->{namespace} = '';
+
+sub default : Private {
+ my ( $self, $c ) = @_;
+ $c->response->body( 'default response' );
+}
+
+sub end : ActionClass('RenderView') {}
+
+1;
Added: Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp/Controller/WS.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp/Controller/WS.pm (rev 0)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp/Controller/WS.pm 2007-11-27 10:53:41 UTC (rev 7168)
@@ -0,0 +1,19 @@
+package TestApp::Controller::WS;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller::SOAP';
+
+sub hello :Local SOAP('DocumentLiteral') {
+ my ($self, $c, $body) = @_;
+ my $world = $body->textContent;
+ $c->stash->{soap}->string_return('Hello '.$world.'!');
+}
+
+sub foo :Local SOAP('HTTPGet') {
+ my ($self, $c) = @_;
+ my $world = $c->req->param('who');
+ $c->stash->{soap}->string_return('Hello '.$world.'!');
+}
+
+1;
Added: Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp.pm (rev 0)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/lib/TestApp.pm 2007-11-27 10:53:41 UTC (rev 7168)
@@ -0,0 +1,13 @@
+package TestApp;
+
+use strict;
+use warnings;
+
+use Catalyst::Runtime;
+use Catalyst;
+
+our $VERSION = '0.01';
+__PACKAGE__->config( name => 'TestApp' );
+__PACKAGE__->setup;
+
+1;
More information about the Catalyst-commits
mailing list