[Catalyst-commits] r7179 - in Catalyst-Model-SOAP/1.0/trunk: . lib lib/Catalyst lib/Catalyst/Model t t/lib

ruoso at dev.catalyst.perl.org ruoso at dev.catalyst.perl.org
Tue Nov 27 11:19:43 GMT 2007


Author: ruoso
Date: 2007-11-27 11:19:43 +0000 (Tue, 27 Nov 2007)
New Revision: 7179

Added:
   Catalyst-Model-SOAP/1.0/trunk/Changes
   Catalyst-Model-SOAP/1.0/trunk/MANIFEST
   Catalyst-Model-SOAP/1.0/trunk/Makefile.PL
   Catalyst-Model-SOAP/1.0/trunk/README
   Catalyst-Model-SOAP/1.0/trunk/catalyst-model-soap.txt
   Catalyst-Model-SOAP/1.0/trunk/lib/
   Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/
   Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model/
   Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model/SOAP.pm
   Catalyst-Model-SOAP/1.0/trunk/t/
   Catalyst-Model-SOAP/1.0/trunk/t/01_basics.t
   Catalyst-Model-SOAP/1.0/trunk/t/lib/
   Catalyst-Model-SOAP/1.0/trunk/t/lib/MyXMLModule.pm
Log:
[C-M-SOAP] getting the last version from git... As the history was too small, it is not being imported...


Added: Catalyst-Model-SOAP/1.0/trunk/Changes
===================================================================
--- Catalyst-Model-SOAP/1.0/trunk/Changes	                        (rev 0)
+++ Catalyst-Model-SOAP/1.0/trunk/Changes	2007-11-27 11:19:43 UTC (rev 7179)
@@ -0,0 +1,5 @@
+commit d01cd969edbddbd62d33a9aaf35bed53b85a2f8e
+Author: Daniel Ruoso <daniel at ruoso.com>
+Date:   Mon Nov 26 14:13:57 2007 +0000
+
+    initial revision

Added: Catalyst-Model-SOAP/1.0/trunk/MANIFEST
===================================================================
--- Catalyst-Model-SOAP/1.0/trunk/MANIFEST	                        (rev 0)
+++ Catalyst-Model-SOAP/1.0/trunk/MANIFEST	2007-11-27 11:19:43 UTC (rev 7179)
@@ -0,0 +1,8 @@
+t/01_basics.t
+t/lib/MyXMLModule.pm
+Changes
+Makefile.PL
+README
+catalyst-model-soap.txt
+MANIFEST
+lib/Catalyst/Model/SOAP.pm

Added: Catalyst-Model-SOAP/1.0/trunk/Makefile.PL
===================================================================
--- Catalyst-Model-SOAP/1.0/trunk/Makefile.PL	                        (rev 0)
+++ Catalyst-Model-SOAP/1.0/trunk/Makefile.PL	2007-11-27 11:19:43 UTC (rev 7179)
@@ -0,0 +1,10 @@
+use 5.008008;
+use ExtUtils::MakeMaker;
+WriteMakefile
+  (
+   NAME              => 'Catalyst::Model::SOAP',
+   VERSION_FROM      => 'lib/Catalyst/Model/SOAP.pm',
+   PREREQ_PM         => { Catalyst::Runtime => 5.7011, XML::Compile::SOAP => 0 },
+   ABSTRACT_FROM  => 'lib/Catalyst/Model/SOAP.pm', # retrieve abstract from module
+   AUTHOR         => 'Daniel Ruoso <daniel.ruoso at verticalone.pt>',
+  );

Added: Catalyst-Model-SOAP/1.0/trunk/README
===================================================================
--- Catalyst-Model-SOAP/1.0/trunk/README	                        (rev 0)
+++ Catalyst-Model-SOAP/1.0/trunk/README	2007-11-27 11:19:43 UTC (rev 7179)
@@ -0,0 +1,67 @@
+NAME
+    Catalyst::Model::SOAP - Map a WSDL to a catalyst model class.
+
+SYNOPSIS
+      {# In the model class...
+          package MyApp::Model::SOAP;
+          use base qw(Catalyst::Model::SOAP);
+          __PACKAGE__->register_wsdl('http://foo.bar/baz.wsdl', 'Bar::Baz');
+          __PACKAGE__->register_wsdl('http://baz.bar/foo.wsdl', 'Bar::Foo');
+      };
+      {# later in some other class..
+         $c->model('Bar::Baz')->getWeather(%arguments);
+         # is then dispatched to the operation getWeather described by the
+         # first wsdl...
+         $c->model('Bar::Foo')->foo(%arguments);
+         # is then dispatched to the operation foo described by the
+         # second wsdl...
+      };
+
+ABSTRACT
+    Create a catalyst model class from a WSDL definition using
+    XML::Compile::SOAP.
+
+DESCRIPTION
+    This module implements a mapping from a wsdl definition, interpreted by
+    XML::Compile::SOAP::WSDL, as a Model class, where each operation in the
+    wsdl file is represented by a method with the same name.
+
+ACCESSORS
+    For each operation, a secondary method called _$operation_data is
+    created. This method returns a list composed by the WSDL object, the
+    operation object and the compiled code ref.
+
+INVOCATION
+    The invocation schema for each operation is documented in
+    XML::Compile::SOAP. Each method is a closure that will call the coderef
+    with the parameters ($self excluded).
+
+XML::Compile::SOAP x SOAP::WSDL
+    For this module, there were two options on the SOAP client
+    implementation. XML::Compile::SOAP and SOAP::WSDL. While both implement
+    all the features expected by this module, the reason to choose
+    XML::Compile::SOAP over SOAP::WSDL resides in the hability to support
+    the specs more closely in the future. And also to provide a better
+    support to handle literal XML messages. As the SOAP::WSDL documentation
+    already states, XML::Compile::SOAP provides an approach much more
+    extensible and close to the specs than SOAP::WSDL.
+
+    Another version of this module may be implemented in the future
+    supporting the other module, but, as for the relationship between
+    Catalyst::Controller::SOAP and Catalyst::Model::SOAP, XML::Compile::SOAP
+    seems to make more sense.
+
+SEE ALSO
+    Catalyst::Controller::SOAP, XML::LibXML, XML::Compile::SOAP
+
+AUTHORS
+    Daniel Ruoso "daniel.ruoso at verticalone.pt"
+
+BUG REPORTS
+    Please submit all bugs regarding "Catalyst::Model::SOAP" to
+    "bug-catalyst-model-soap at rt.cpan.org"
+
+LICENSE
+    This library is free software, you can redistribute it and/or modify it
+    under the same terms as Perl itself.
+

Added: Catalyst-Model-SOAP/1.0/trunk/catalyst-model-soap.txt
===================================================================
--- Catalyst-Model-SOAP/1.0/trunk/catalyst-model-soap.txt	                        (rev 0)
+++ Catalyst-Model-SOAP/1.0/trunk/catalyst-model-soap.txt	2007-11-27 11:19:43 UTC (rev 7179)
@@ -0,0 +1,18 @@
+{# In the model class...
+    package MyApp::Model::SOAP;
+    use base qw(Catalyst::Model::SOAP);
+
+    __PACKAGE__->register_wsdl('http://foo.bar/baz.wsdl', 'Bar::Baz');
+    __PACKAGE__->register_wsdl('http://baz.bar/foo.wsdl', 'Bar::Foo');
+};
+
+{# later in some other class..
+
+   $c->model('Bar::Baz')->getWeather(%arguments);
+   # is then dispatched to the operation getWeather described by the
+   # first wsdl...
+
+   $c->model('Bar::Foo')->foo(%arguments);
+   # is then dispatched to the operation foo described by the
+   # second wsdl...
+};

Added: Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model/SOAP.pm
===================================================================
--- Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model/SOAP.pm	                        (rev 0)
+++ Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model/SOAP.pm	2007-11-27 11:19:43 UTC (rev 7179)
@@ -0,0 +1,95 @@
+{   package Catalyst::Model::SOAP;
+    use strict;
+    use warnings;
+    use XML::Compile::SOAP;
+    our $VERSION = '0.0.1';
+
+    sub register_wsdl {
+
+    }
+};
+1;
+
+__END__
+
+=head1 NAME
+
+Catalyst::Model::SOAP - Map a WSDL to a catalyst model class.
+
+=head1 SYNOPSIS
+
+  {# In the model class...
+      package MyApp::Model::SOAP;
+      use base qw(Catalyst::Model::SOAP);
+      __PACKAGE__->register_wsdl('http://foo.bar/baz.wsdl', 'Bar::Baz');
+      __PACKAGE__->register_wsdl('http://baz.bar/foo.wsdl', 'Bar::Foo');
+  };
+  {# later in some other class..
+     $c->model('Bar::Baz')->getWeather(%arguments);
+     # is then dispatched to the operation getWeather described by the
+     # first wsdl...
+     $c->model('Bar::Foo')->foo(%arguments);
+     # is then dispatched to the operation foo described by the
+     # second wsdl...
+  };
+
+=head1 ABSTRACT
+
+Create a catalyst model class from a WSDL definition using
+XML::Compile::SOAP.
+
+=head1 DESCRIPTION
+
+This module implements a mapping from a wsdl definition, interpreted
+by XML::Compile::SOAP::WSDL, as a Model class, where each operation in
+the wsdl file is represented by a method with the same name.
+
+=head1 ACCESSORS
+
+For each operation, a secondary method called _$operation_data is
+created. This method returns a list composed by the WSDL object, the
+operation object and the compiled code ref.
+
+=head1 INVOCATION
+
+The invocation schema for each operation is documented in
+XML::Compile::SOAP. Each method is a closure that will call the
+coderef with the parameters ($self excluded).
+
+=head1 XML::Compile::SOAP x SOAP::WSDL
+
+For this module, there were two options on the SOAP client
+implementation. XML::Compile::SOAP and SOAP::WSDL. While both
+implement all the features expected by this module, the reason to
+choose XML::Compile::SOAP over SOAP::WSDL resides in the hability to
+support the specs more closely in the future. And also to provide a
+better support to handle literal XML messages. As the SOAP::WSDL
+documentation already states, XML::Compile::SOAP provides an approach
+much more extensible and close to the specs than SOAP::WSDL.
+
+Another version of this module may be implemented in the future
+supporting the other module, but, as for the relationship between
+Catalyst::Controller::SOAP and Catalyst::Model::SOAP,
+XML::Compile::SOAP seems to make more sense.
+
+=head1 SEE ALSO
+
+L<Catalyst::Controller::SOAP>, L<XML::LibXML>, L<XML::Compile::SOAP>
+
+=head1 AUTHORS
+
+Daniel Ruoso C<daniel.ruoso at verticalone.pt>
+
+=head1 BUG REPORTS
+
+Please submit all bugs regarding C<Catalyst::Model::SOAP> to
+C<bug-catalyst-model-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
+

Added: Catalyst-Model-SOAP/1.0/trunk/t/01_basics.t
===================================================================
--- Catalyst-Model-SOAP/1.0/trunk/t/01_basics.t	                        (rev 0)
+++ Catalyst-Model-SOAP/1.0/trunk/t/01_basics.t	2007-11-27 11:19:43 UTC (rev 7179)
@@ -0,0 +1,22 @@
+
+use Test::More tests => 7;
+use Symbol;
+BEGIN { use_ok('Catalyst::Model::SOAP') };
+
+use lib 't/lib/';
+use MyXMLModule;
+
+{
+    package MyFooModel;
+    use base qw(Catalyst::Model::SOAP);
+    __PACKAGE__->register_wsdl('http://foo.bar/baz.wsdl', 'Bar::Baz');
+};
+
+ok(defined *::Bar::Baz, 'Loading the wsdl pre-registers a class.');
+ok(defined *::Bar::Baz::op1, 'Loading the wsdl pre-registers the method.');
+ok(defined *::Bar::Baz::_op1_data, 'Loading the wsdl pre-register the helper-method');
+is(::Bar::Baz->op1, 'op1', 'The method calls the coderef.');
+my @data = ::Bar::Baz->_op1_data();
+is(ref $data[0], 'MyXML::WSDL11', 'The first element in the data is the wsdl object');
+is(ref $data[1], 'MyXML::Operation', 'The second element in the data is the operation object');
+is(ref $data[2], 'CODE', 'The third element in the data is the code reference');

Added: Catalyst-Model-SOAP/1.0/trunk/t/lib/MyXMLModule.pm
===================================================================
--- Catalyst-Model-SOAP/1.0/trunk/t/lib/MyXMLModule.pm	                        (rev 0)
+++ Catalyst-Model-SOAP/1.0/trunk/t/lib/MyXMLModule.pm	2007-11-27 11:19:43 UTC (rev 7179)
@@ -0,0 +1,43 @@
+# In order to simulate the behaviour, I'll re-write the methods of
+# XML::Compile::SOAP::WSDL11, returning a known structure so that we
+# can predict the answer and also avoid centering the test on
+# XML::Compile::SOAP and depending on network.
+{
+    package XML::Compile::SOAP::WSDL11;
+    sub new {
+        return bless { symbol => gensym() }, MyXML::WSDL11;
+    }
+};
+{
+    package MyXML::WSDL11;
+    sub operations {
+        return
+          [
+           (bless { name => 'op1', service => 'sv1', port => 'pt1' }, MyXML::Operation),
+           (bless { name => 'op2', service => 'sv1', port => 'pt1' }, MyXML::Operation),
+           (bless { name => 'op3', service => 'sv1', port => 'pt2' }, MyXML::Operation),
+           (bless { name => 'op4', service => 'sv2', port => 'pt3' }, MyXML::Operation),
+           (bless { name => 'op5', service => 'sv2', port => 'pt4' }, MyXML::Operation),
+          ]
+    }
+};
+{
+    package MyXML::Operation;
+    sub compileClient {
+        my $self = shift;
+        return sub { return $self->{name} };
+    }
+    sub port {
+        my $self = shift;
+        return $self->{port};
+    }
+    sub service {
+        my $self = shift;
+        return $self->{service};
+    }
+    sub name {
+        my $self = shift;
+        return $self->{name};
+    }
+};
+1;




More information about the Catalyst-commits mailing list