[Catalyst-commits] r7391 - in Catalyst-Controller-SOAP/1.0/tags: . 0.2.0/lib/Catalyst/Action 0.2.0/lib/Catalyst/Action/SOAP 0.2.0/lib/Catalyst/Controller 0.2.0/t

ruoso at dev.catalyst.perl.org ruoso at dev.catalyst.perl.org
Wed Jan 16 12:29:16 GMT 2008


Author: ruoso
Date: 2008-01-16 12:29:16 +0000 (Wed, 16 Jan 2008)
New Revision: 7391

Added:
   Catalyst-Controller-SOAP/1.0/tags/0.2.0/
   Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP.pm
   Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/DocumentLiteral.pm
   Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/RPCEndpoint.pm
   Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Controller/SOAP.pm
   Catalyst-Controller-SOAP/1.0/tags/0.2.0/t/PostApp.t
Removed:
   Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP.pm
   Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/DocumentLiteral.pm
   Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/RPCEndpoint.pm
   Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Controller/SOAP.pm
   Catalyst-Controller-SOAP/1.0/tags/0.2.0/t/PostApp.t
Log:
[C-C-SOAP] Marking the new release

Copied: Catalyst-Controller-SOAP/1.0/tags/0.2.0 (from rev 7284, Catalyst-Controller-SOAP/1.0/trunk)

Deleted: Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/DocumentLiteral.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/DocumentLiteral.pm	2007-12-12 03:32:42 UTC (rev 7284)
+++ Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/DocumentLiteral.pm	2008-01-16 12:29:16 UTC (rev 7391)
@@ -1,56 +0,0 @@
-{ package Catalyst::Action::SOAP::DocumentLiteral;
-
-  use base qw/Catalyst::Action::SOAP/;
-
-  sub execute {
-      my $self = shift;
-      my ( $controller, $c ) = @_;
-      $self->prepare_soap_helper($c);
-      $self->prepare_soap_xml_post($c);
-      unless ($c->stash->{soap}->fault) {
-          my $envelope = $c->stash->{soap}->parsed_envelope;
-          my ($body) = $envelope->getElementsByTagName('Body',0);
-          $self->NEXT::execute($controller, $c, $body);
-      }
-  }
-};
-
-1;
-
-__END__
-
-=head1 NAME
-
-Catalyst::Action::SOAP::DocumentLiteral - Document Literal service
-
-=head1 SYNOPSIS
-
-  # not used directly.
-
-=head1 DESCRIPTION
-
-This action implements a simple parse of the envelope and passing the
-body to the service as a xml object.
-
-=head1 TODO
-
-Almost all the SOAP protocol is unsupported, only the method
-dispatching and, optionally, the soap-decoding of the arguments are
-made.
-
-=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
-

Copied: Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/DocumentLiteral.pm (from rev 7390, Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/DocumentLiteral.pm)
===================================================================
--- Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/DocumentLiteral.pm	                        (rev 0)
+++ Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/DocumentLiteral.pm	2008-01-16 12:29:16 UTC (rev 7391)
@@ -0,0 +1,58 @@
+{ package Catalyst::Action::SOAP::DocumentLiteral;
+
+  use base qw/Catalyst::Action::SOAP/;
+  use constant NS_SOAP_ENV => "http://schemas.xmlsoap.org/soap/envelope/";
+
+  sub execute {
+      my $self = shift;
+      my ( $controller, $c ) = @_;
+      $self->prepare_soap_helper($c);
+      $self->prepare_soap_xml_post($c);
+      unless ($c->stash->{soap}->fault) {
+          my $envelope = $c->stash->{soap}->parsed_envelope;
+          my $namespace = $c->stash->{soap}->namespace || NS_SOAP_ENV;
+          my ($body) = $envelope->getElementsByTagNameNS($namespace, 'Body');
+          $self->NEXT::execute($controller, $c, $body);
+      }
+  }
+};
+
+1;
+
+__END__
+
+=head1 NAME
+
+Catalyst::Action::SOAP::DocumentLiteral - Document Literal service
+
+=head1 SYNOPSIS
+
+  # not used directly.
+
+=head1 DESCRIPTION
+
+This action implements a simple parse of the envelope and passing the
+body to the service as a xml object.
+
+=head1 TODO
+
+Almost all the SOAP protocol is unsupported, only the method
+dispatching and, optionally, the soap-decoding of the arguments are
+made.
+
+=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
+

Deleted: Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/RPCEndpoint.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/RPCEndpoint.pm	2007-12-12 03:32:42 UTC (rev 7284)
+++ Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/RPCEndpoint.pm	2008-01-16 12:29:16 UTC (rev 7391)
@@ -1,80 +0,0 @@
-{ package Catalyst::Action::SOAP::RPCEndpoint;
-
-  use base qw/Catalyst::Action::SOAP/;
-
-  sub execute {
-      my $self = shift;
-      my ( $controller, $c ) = @_;
-
-      $self->prepare_soap_helper($c);
-      $self->prepare_soap_xml_post($c);
-      unless ($c->stash->{soap}->fault) {
-          my $envelope = $c->stash->{soap}->parsed_envelope;
-          my ($body) = $envelope->getElementsByTagName('Body',0);
-          my @children = $body->getChildNodes();
-          if (scalar @children != 1) {
-              $c->stash->{soap}->fault
-                ({ code => { 'env:Sender' => 'env:Body' },
-                   reason => 'Bad Body', detail =>
-                   'RPC messages should contain only one element inside body'})
-            } else {
-                my $operation = $children[0]->nodeName();
-                my $arguments = $children[0]->getChildNodes();
-                $c->stash->{soap}->arguments($arguments);
-                if (!grep { /RPC(Encoded|Literal)/ } @{$controller->action_for($operation)->attributes->{ActionClass}}) {
-                    $c->stash->{soap}->fault
-                      ({ code => { 'env:Sender' => 'env:Body' },
-                         reason => 'Bad Operation', detail =>
-                         'Invalid Operation'})
-                } else {
-                    # this is our RPC action
-                    $c->forward($operation);
-                }
-            }
-      }
-  }
-};
-
-1;
-
-__END__
-
-=head1 NAME
-
-Catalyst::Action::SOAP::RPCEndpoint - RPC Dispatcher
-
-=head1 SYNOPSIS
-
-  # not used directly.
-
-=head1 DESCRIPTION
-
-This class is used by L<Catalyst::Controller::SOAP> to dispatch to the
-RPC operations inside a controller. These operations are quite
-different from the others, as they are seen by Catalyst as this single
-action. During the registering phase, the soap rpc operations are
-included in the hash that is sent to this object, so they can be
-invoked later.
-
-=head1 TODO
-
-Almost all the SOAP protocol is unsupported, only the method
-dispatching and, optionally, the soap-decoding of the arguments are
-made.
-
-=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
-

Copied: Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/RPCEndpoint.pm (from rev 7390, Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/RPCEndpoint.pm)
===================================================================
--- Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/RPCEndpoint.pm	                        (rev 0)
+++ Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP/RPCEndpoint.pm	2008-01-16 12:29:16 UTC (rev 7391)
@@ -0,0 +1,85 @@
+{ package Catalyst::Action::SOAP::RPCEndpoint;
+
+  use base qw/Catalyst::Action::SOAP/;
+  use constant NS_SOAP_ENV => "http://schemas.xmlsoap.org/soap/envelope/";
+
+  sub execute {
+      my $self = shift;
+      my ( $controller, $c ) = @_;
+
+      $self->prepare_soap_helper($c);
+      $self->prepare_soap_xml_post($c);
+      unless ($c->stash->{soap}->fault) {
+          my $envelope = $c->stash->{soap}->parsed_envelope;
+          my $namespace = $c->stash->{soap}->namespace || NS_SOAP_ENV;
+          my ($body) = $envelope->getElementsByTagNameNS($namespace,'Body',0);
+          my @children = $body->getChildNodes();
+          if (scalar @children != 1) {
+              $c->stash->{soap}->fault
+                ({ code => { 'env:Sender' => 'env:Body' },
+                   reason => 'Bad Body', detail =>
+                   'RPC messages should contain only one element inside body'})
+            } else {
+                my ($smthing, $operation) = split /:/, $children[0]->nodeName();
+                $operation ||= $smthing; # if there's no ns prefix,
+                                         # operation is the first
+                                         # part.
+                my $arguments = $children[0]->getChildNodes();
+                $c->stash->{soap}->arguments($arguments);
+                if (!grep { /RPC(Encoded|Literal)/ } @{$controller->action_for($operation)->attributes->{ActionClass}}) {
+                    $c->stash->{soap}->fault
+                      ({ code => { 'env:Sender' => 'env:Body' },
+                         reason => 'Bad Operation', detail =>
+                         'Invalid Operation'})
+                } else {
+                    # this is our RPC action
+                    $c->forward($operation);
+                }
+            }
+      }
+  }
+};
+
+1;
+
+__END__
+
+=head1 NAME
+
+Catalyst::Action::SOAP::RPCEndpoint - RPC Dispatcher
+
+=head1 SYNOPSIS
+
+  # not used directly.
+
+=head1 DESCRIPTION
+
+This class is used by L<Catalyst::Controller::SOAP> to dispatch to the
+RPC operations inside a controller. These operations are quite
+different from the others, as they are seen by Catalyst as this single
+action. During the registering phase, the soap rpc operations are
+included in the hash that is sent to this object, so they can be
+invoked later.
+
+=head1 TODO
+
+Almost all the SOAP protocol is unsupported, only the method
+dispatching and, optionally, the soap-decoding of the arguments are
+made.
+
+=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
+

Deleted: Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP.pm	2007-12-12 03:32:42 UTC (rev 7284)
+++ Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP.pm	2008-01-16 12:29:16 UTC (rev 7391)
@@ -1,76 +0,0 @@
-{ package Catalyst::Action::SOAP;
-
-  use base qw/Catalyst::Action/;
-  use XML::LibXML;
-
-  __PACKAGE__->mk_accessors(qw/xml_parser/);
-
-  sub new {
-      my $class = shift;
-      my $self = $class->SUPER::new(@_);
-      $self->xml_parser(XML::LibXML->new());
-      return $self;
-  }
-
-  sub prepare_soap_helper {
-      my ($self, $c) = @_;
-      $c->stash->{soap} = Catalyst::Controller::SOAP::Helper->new();
-  }
-
-  sub prepare_soap_xml_post {
-      my ($self, $c) = @_;
-      if ($c->req->content_type =~ /application\/soap\+xml/ &&
-          $c->req->method eq 'POST') {
-          my $body = $c->req->body;
-          my $xml_str = join '', <$body>;
-          eval {
-              $c->stash->{soap}->envelope($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 => $@});
-          }
-      } else {
-          $c->stash->{soap}->fault({ code => 'env:Sender', reason => 'Bad content-type/method'});
-      }
-  }
-};
-
-1;
-
-__END__
-
-=head1 NAME
-
-Catalyst::Action::SOAP - Action superclass
-
-=head1 SYNOPSIS
-
-  # not used directly.
-
-=head1 DESCRIPTION
-
-This is the superclass used by the Document and the RPC actions.
-
-=head1 TODO
-
-Almost all the SOAP protocol is unsupported, only the method
-dispatching and, optionally, the soap-decoding of the arguments are
-made.
-
-=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
-

Copied: Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP.pm (from rev 7379, Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP.pm)
===================================================================
--- Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP.pm	                        (rev 0)
+++ Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Action/SOAP.pm	2008-01-16 12:29:16 UTC (rev 7391)
@@ -0,0 +1,77 @@
+{ package Catalyst::Action::SOAP;
+
+  use base qw/Catalyst::Action/;
+  use XML::LibXML;
+
+  __PACKAGE__->mk_accessors(qw/xml_parser/);
+
+  sub new {
+      my $class = shift;
+      my $self = $class->SUPER::new(@_);
+      $self->xml_parser(XML::LibXML->new());
+      return $self;
+  }
+
+  sub prepare_soap_helper {
+      my ($self, $c) = @_;
+      $c->stash->{soap} = Catalyst::Controller::SOAP::Helper->new();
+  }
+
+  sub prepare_soap_xml_post {
+      my ($self, $c) = @_;
+      # This should be applocation/soap+xml, but some clients doesn't seem to respect that.
+      if ($c->req->content_type =~ /xml/ &&
+          $c->req->method eq 'POST') {
+          my $body = $c->req->body;
+          my $xml_str = join '', <$body>;
+          eval {
+              $c->stash->{soap}->envelope($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 => $@});
+          }
+      } else {
+          $c->stash->{soap}->fault({ code => 'env:Sender', reason => 'Bad content-type/method'});
+      }
+  }
+};
+
+1;
+
+__END__
+
+=head1 NAME
+
+Catalyst::Action::SOAP - Action superclass
+
+=head1 SYNOPSIS
+
+  # not used directly.
+
+=head1 DESCRIPTION
+
+This is the superclass used by the Document and the RPC actions.
+
+=head1 TODO
+
+Almost all the SOAP protocol is unsupported, only the method
+dispatching and, optionally, the soap-decoding of the arguments are
+made.
+
+=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
+

Deleted: Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Controller/SOAP.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm	2007-12-12 03:32:42 UTC (rev 7284)
+++ Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Controller/SOAP.pm	2008-01-16 12:29:16 UTC (rev 7391)
@@ -1,278 +0,0 @@
-{   package Catalyst::Controller::SOAP;
-
-    use strict;
-    use base qw/Catalyst::Controller/;
-    use XML::LibXML;
-
-    use constant NS_SOAP_ENV => "http://www.w3.org/2003/05/soap-envelope";
-    our $VERSION = '0.1.1';
-
-    sub _parse_SOAP_attr {
-        my ($self, $c, $name, $value) = @_;
-        my $actionclass = ($value =~ /^\+/ ? $value :
-          'Catalyst::Action::SOAP::'.$value);
-        (
-         ActionClass => $actionclass,
-        )
-    }
-
-    # this is implemented as to respond a SOAP message according to
-    # what has been sent to $c->stash->{soap}
-    sub end : Private {
-        my ($self, $c) = (shift, shift);
-        my $soap = $c->stash->{soap};
-
-        return $self->NEXT::end($c, @_) unless $soap;
-
-        my $response = XML::LibXML->createDocument();
-
-        my $envelope = $response->createElementNS
-          (NS_SOAP_ENV,"Envelope");
-
-        $response->setDocumentElement($envelope);
-
-        # TODO: we don't support header generation in response yet.
-
-        my $body = $response->createElementNS
-          (NS_SOAP_ENV,"Body");
-
-        $envelope->appendChild($body);
-
-        if ($soap->fault) {
-            my $fault = $response->createElementNS
-              (NS_SOAP_ENV, "Fault");
-            $body->appendChild($fault);
-
-            my $code = $response->createElementNS
-              (NS_SOAP_ENV, "Code");
-            $fault->appendChild($code);
-
-            $self->_generate_Fault_Code($response,$code,$soap->fault->{code});
-
-            if ($soap->fault->{reason}) {
-                my $reason = $response->createElementNS
-                  (NS_SOAP_ENV, "Reason");
-                $fault->appendChild($reason);
-                # TODO: we don't support the xml:lang attribute yet.
-                my $text = $response->createElementNS
-                  (NS_SOAP_ENV, "Text");
-                $reason->appendChild($text);
-                $text->appendText($soap->fault->{reason});
-            }
-            if ($soap->fault->{detail}) {
-                my $detail = $response->createElementNS
-                  (NS_SOAP_ENV, "Detail");
-                $fault->appendChild($detail);
-                # TODO: we don't support the xml:lang attribute yet.
-                my $text = $response->createElementNS
-                  (NS_SOAP_ENV, "Text");
-                $detail->appendChild($text);
-                $text->appendText($soap->fault->{detail});
-            }
-        } else {
-            # TODO: Generate the body.
-            # At this moment, for the sake of getting something ready,
-            # let's implement the string return.
-            if ($soap->string_return) {
-                $body->appendText($soap->string_return);
-            } elsif (my $lit = $soap->literal_return) {
-                if (ref $lit eq 'XML::LibXML::NodeList') {
-                    for ($lit->get_nodelist) {
-                        $body->appendChild($_);
-                    }
-                } else {
-                    $body->appendChild($lit);
-                }
-            }
-        }
-
-        $c->res->body($envelope->toString());
-    }
-
-    sub _generate_Fault_Code {
-        my ($self, $document, $codenode, $codeValue) = @_;
-
-        my $value = $document->createElementNS
-          (NS_SOAP_ENV, "Value");
-        if (ref $codeValue eq 'ARRAY') {
-            $value->appendText($codeValue->[0]);
-            my $subcode = $document->createElementNS
-              (NS_SOAP_ENV, 'SubCode');
-            $codenode->appendChild($value);
-            $codenode->appendChild($subcode);
-            $self->_generate_Fault_Code($document, $subcode, $codeValue->[1]);
-        } else {
-            $value->appendText($codeValue);
-            $codenode->appendChild($value);
-        }
-    }
-
-
-};
-
-{   package Catalyst::Controller::SOAP::Helper;
-
-    use base qw(Class::Accessor::Fast);
-
-    __PACKAGE__->mk_accessors(qw{envelope parsed_envelope arguments fault
-                               encoded_return literal_return string_return});
-
-
-};
-
-1;
-
-__END__
-
-=head1 NAME
-
-Catalyst::Controller::SOAP - Catalyst SOAP Controller
-
-=head1 SYNOPSIS
-
-    package MyApp::Controller::Example;
-    use base 'Catalyst::Controller::SOAP';
-
-    # available in "/example" as operation "ping". The arguments are
-    # treated as a literal document and passed to the method as a
-    # XML::LibXML object
-    # Using XML::Compile here will help you reading the message.
-    sub ping : SOAP('RPCLiteral') {
-        my ( $self, $c, $xml) = @_;
-        my $name = $xml->findValue('some xpath expression');
-    }
-
-    # avaiable as "/example/world" in document context. The entire body
-    # is delivered to the method as a XML::LibXML object.
-    # Using XML::Compile here will help you reading the message.
-    sub world :Local SOAP('DocumentLiteral')  {
-        my ($self, $c, $xml) = @_;
-    }
-
-    # avaiable as "/example/get" in HTTP get context.
-    # the get attributes will be available as any other
-    # get operation in Catalyst.
-    sub get :Local SOAP('HTTPGet')  {
-        my ($self, $c) = @_;
-    }
-
-    # this is the endpoint from where the RPC operations will be
-    # dispatched. This code won't be executed at all.
-    # See Catalyst::Controller::SOAP::RPC.
-    sub index :Local 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.It is important to notice that this
-controller declares by default an index operation which will dispatch
-the RPC operations under this class.
-
-=head1 ATTRIBUTES
-
-This class implements the SOAP attribute wich is used to do the
-mapping of that operation to the apropriate action class. The name of
-the class used is formed as Catalyst::Action::SOAP::$value, unless the
-parameter of the attribute starts with a '+', which implies complete
-namespace.
-
-The implementation of SOAP Action classes helps delivering specific
-SOAP scenarios, like HTTP GET, RPC Encoded, RPC Literal or Document
-Literal, or even Document RDF or just about any required combination.
-
-See L<Catalyst::Action::SOAP::DocumentLiteral> for an example.
-
-=head1 ACCESSORS
-
-Once you tagged one of the methods, you'll have an $c->stash->{soap}
-accessor which will return an C<Catalyst::Controller::SOAP::Helper>
-object. It's important to notice that this is achieved by the fact
-that all the SOAP Action classes are subclasses of
-Catalyst::Action::SOAP, which implements most of that.
-
-You can query this object as follows:
-
-=over 4
-
-=item $c->stash->{soap}->envelope()
-
-The original SOAP envelope as string.
-
-=item $c->stash->{soap}->parsed_envelope()
-
-The parsed envelope as an XML::LibXML object.
-
-=item $c->stash->{soap}->arguments()
-
-The arguments of a RPC call.
-
-=item $c->stash->{soap}->fault({code => $code,reason => $reason, detail => $detail])
-
-Allows you to set fault code and message. Optionally, you may define
-the code itself as an arrayref where the first item will be this code
-and the second will be the subcode, which recursively may be another
-arrayref.
-
-=item $c->stash->{soap}->encoded_return(\@data)
-
-This method will prepare the return value to be a soap encoded data.
-
-  # TODO: At this moment, only Literals are working...
-
-=item $c->stash->{soap}->literal_return($xml_node)
-
-This method will prepare the return value to be a literal XML
-document, in this case, you can pass just the node that will be the
-root in the return message or a nodelist.
-
-Using XML::Compile will help to elaborate schema based returns.
-
-=item $c->stash->{soap}->string_return($non_xml_text)
-
-In this case, the given text is encoded as CDATA inside the SOAP
-message.
-
-=back
-
-=head1 TODO
-
-At this moment, almost everything is still to be done. The only thing
-done right now is getting the body from the message and dispatching
-the correct method. It is strongly recommended to use XML::Compile as
-a tool to deal with the XML nodes.
-
-The SOAP Encoding support is also missing, when that is ready you'll
-be able to do something like the code below:
-
-    # available in "/example" as operation "echo"
-    # parsing the arguments as soap-encoded.
-    sub echo : SOAP('RPCEncoded') {
-        my ( $self, $c, @args ) = @_;
-    }
-
-=head1 SEE ALSO
-
-L<Catalyst::Action::SOAP>, L<XML::LibXML>, L<XML::Compile>
-L<Catalyst::Action::SOAP::DocumentLiteral>,
-L<Catalyst::Action::SOAP::RPCLiteral>,
-L<Catalyst::Action::SOAP::HTTPGet>
-
-=head1 AUTHORS
-
-Daniel Ruoso C<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

Copied: Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Controller/SOAP.pm (from rev 7390, Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm)
===================================================================
--- Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Controller/SOAP.pm	                        (rev 0)
+++ Catalyst-Controller-SOAP/1.0/tags/0.2.0/lib/Catalyst/Controller/SOAP.pm	2008-01-16 12:29:16 UTC (rev 7391)
@@ -0,0 +1,281 @@
+{   package Catalyst::Controller::SOAP;
+
+    use strict;
+    use base qw/Catalyst::Controller/;
+    use XML::LibXML;
+
+    use constant NS_SOAP_ENV => "http://schemas.xmlsoap.org/soap/envelope/";
+
+    our $VERSION = '0.2.0';
+
+    sub _parse_SOAP_attr {
+        my ($self, $c, $name, $value) = @_;
+        my $actionclass = ($value =~ /^\+/ ? $value :
+          'Catalyst::Action::SOAP::'.$value);
+        (
+         ActionClass => $actionclass,
+        )
+    }
+
+    # this is implemented as to respond a SOAP message according to
+    # what has been sent to $c->stash->{soap}
+    sub end : Private {
+        my ($self, $c) = (shift, shift);
+        my $soap = $c->stash->{soap};
+
+        return $self->NEXT::end($c, @_) unless $soap;
+
+        my $namespace = $soap->namespace || NS_SOAP_ENV;
+        my $response = XML::LibXML->createDocument();
+
+        my $envelope = $response->createElementNS
+          ($namespace,"Envelope");
+
+        $response->setDocumentElement($envelope);
+
+        # TODO: we don't support header generation in response yet.
+
+        my $body = $response->createElementNS
+          ($namespace,"Body");
+
+        $envelope->appendChild($body);
+
+        if ($soap->fault) {
+            my $fault = $response->createElementNS
+              ($namespace, "Fault");
+            $body->appendChild($fault);
+
+            my $code = $response->createElementNS
+              ($namespace, "Code");
+            $fault->appendChild($code);
+
+            $self->_generate_Fault_Code($response,$code,$soap->fault->{code}, $namespace);
+
+            if ($soap->fault->{reason}) {
+                my $reason = $response->createElementNS
+                  ($namespace, "Reason");
+                $fault->appendChild($reason);
+                # TODO: we don't support the xml:lang attribute yet.
+                my $text = $response->createElementNS
+                  ($namespace, "Text");
+                $reason->appendChild($text);
+                $text->appendText($soap->fault->{reason});
+            }
+            if ($soap->fault->{detail}) {
+                my $detail = $response->createElementNS
+                  ($namespace, "Detail");
+                $fault->appendChild($detail);
+                # TODO: we don't support the xml:lang attribute yet.
+                my $text = $response->createElementNS
+                  ($namespace, "Text");
+                $detail->appendChild($text);
+                $text->appendText($soap->fault->{detail});
+            }
+        } else {
+            # TODO: Generate the body.
+            # At this moment, for the sake of getting something ready,
+            # let's implement the string return.
+            if ($soap->string_return) {
+                $body->appendText($soap->string_return);
+            } elsif (my $lit = $soap->literal_return) {
+                if (ref $lit eq 'XML::LibXML::NodeList') {
+                    for ($lit->get_nodelist) {
+                        $body->appendChild($_);
+                    }
+                } else {
+                    $body->appendChild($lit);
+                }
+            }
+        }
+
+        $c->res->content_type('text/xml');
+        $c->res->body($envelope->toString());
+    }
+
+    sub _generate_Fault_Code {
+        my ($self, $document, $codenode, $codeValue, $namespace) = @_;
+
+        my $value = $document->createElementNS
+          ($namespace, "Value");
+        if (ref $codeValue eq 'ARRAY') {
+            $value->appendText($codeValue->[0]);
+            my $subcode = $document->createElementNS
+              ($namespace, 'SubCode');
+            $codenode->appendChild($value);
+            $codenode->appendChild($subcode);
+            $self->_generate_Fault_Code($document, $subcode, $codeValue->[1], $namespace);
+        } else {
+            $value->appendText($codeValue);
+            $codenode->appendChild($value);
+        }
+    }
+
+
+};
+
+{   package Catalyst::Controller::SOAP::Helper;
+
+    use base qw(Class::Accessor::Fast);
+
+    __PACKAGE__->mk_accessors(qw{envelope parsed_envelope arguments fault namespace 
+                               encoded_return literal_return string_return});
+
+
+};
+
+1;
+
+__END__
+
+=head1 NAME
+
+Catalyst::Controller::SOAP - Catalyst SOAP Controller
+
+=head1 SYNOPSIS
+
+    package MyApp::Controller::Example;
+    use base 'Catalyst::Controller::SOAP';
+
+    # available in "/example" as operation "ping". The arguments are
+    # treated as a literal document and passed to the method as a
+    # XML::LibXML object
+    # Using XML::Compile here will help you reading the message.
+    sub ping : SOAP('RPCLiteral') {
+        my ( $self, $c, $xml) = @_;
+        my $name = $xml->findValue('some xpath expression');
+    }
+
+    # avaiable as "/example/world" in document context. The entire body
+    # is delivered to the method as a XML::LibXML object.
+    # Using XML::Compile here will help you reading the message.
+    sub world :Local SOAP('DocumentLiteral')  {
+        my ($self, $c, $xml) = @_;
+    }
+
+    # avaiable as "/example/get" in HTTP get context.
+    # the get attributes will be available as any other
+    # get operation in Catalyst.
+    sub get :Local SOAP('HTTPGet')  {
+        my ($self, $c) = @_;
+    }
+
+    # this is the endpoint from where the RPC operations will be
+    # dispatched. This code won't be executed at all.
+    # See Catalyst::Controller::SOAP::RPC.
+    sub index :Local 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.It is important to notice that this
+controller declares by default an index operation which will dispatch
+the RPC operations under this class.
+
+=head1 ATTRIBUTES
+
+This class implements the SOAP attribute wich is used to do the
+mapping of that operation to the apropriate action class. The name of
+the class used is formed as Catalyst::Action::SOAP::$value, unless the
+parameter of the attribute starts with a '+', which implies complete
+namespace.
+
+The implementation of SOAP Action classes helps delivering specific
+SOAP scenarios, like HTTP GET, RPC Encoded, RPC Literal or Document
+Literal, or even Document RDF or just about any required combination.
+
+See L<Catalyst::Action::SOAP::DocumentLiteral> for an example.
+
+=head1 ACCESSORS
+
+Once you tagged one of the methods, you'll have an $c->stash->{soap}
+accessor which will return an C<Catalyst::Controller::SOAP::Helper>
+object. It's important to notice that this is achieved by the fact
+that all the SOAP Action classes are subclasses of
+Catalyst::Action::SOAP, which implements most of that.
+
+You can query this object as follows:
+
+=over 4
+
+=item $c->stash->{soap}->envelope()
+
+The original SOAP envelope as string.
+
+=item $c->stash->{soap}->parsed_envelope()
+
+The parsed envelope as an XML::LibXML object.
+
+=item $c->stash->{soap}->arguments()
+
+The arguments of a RPC call.
+
+=item $c->stash->{soap}->fault({code => $code,reason => $reason, detail => $detail])
+
+Allows you to set fault code and message. Optionally, you may define
+the code itself as an arrayref where the first item will be this code
+and the second will be the subcode, which recursively may be another
+arrayref.
+
+=item $c->stash->{soap}->encoded_return(\@data)
+
+This method will prepare the return value to be a soap encoded data.
+
+  # TODO: At this moment, only Literals are working...
+
+=item $c->stash->{soap}->literal_return($xml_node)
+
+This method will prepare the return value to be a literal XML
+document, in this case, you can pass just the node that will be the
+root in the return message or a nodelist.
+
+Using XML::Compile will help to elaborate schema based returns.
+
+=item $c->stash->{soap}->string_return($non_xml_text)
+
+In this case, the given text is encoded as CDATA inside the SOAP
+message.
+
+=back
+
+=head1 TODO
+
+At this moment, almost everything is still to be done. The only thing
+done right now is getting the body from the message and dispatching
+the correct method. It is strongly recommended to use XML::Compile as
+a tool to deal with the XML nodes.
+
+The SOAP Encoding support is also missing, when that is ready you'll
+be able to do something like the code below:
+
+    # available in "/example" as operation "echo"
+    # parsing the arguments as soap-encoded.
+    sub echo : SOAP('RPCEncoded') {
+        my ( $self, $c, @args ) = @_;
+    }
+
+=head1 SEE ALSO
+
+L<Catalyst::Action::SOAP>, L<XML::LibXML>, L<XML::Compile>
+L<Catalyst::Action::SOAP::DocumentLiteral>,
+L<Catalyst::Action::SOAP::RPCLiteral>,
+L<Catalyst::Action::SOAP::HTTPGet>
+
+=head1 AUTHORS
+
+Daniel Ruoso C<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

Deleted: Catalyst-Controller-SOAP/1.0/tags/0.2.0/t/PostApp.t
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t	2007-12-12 03:32:42 UTC (rev 7284)
+++ Catalyst-Controller-SOAP/1.0/tags/0.2.0/t/PostApp.t	2008-01-16 12:29:16 UTC (rev 7391)
@@ -1,60 +0,0 @@
-use Test::More tests => 3;
-use File::Spec::Functions;
-use HTTP::Response;
-use IPC::Open3;
-use Symbol;
-
-my $response;
-
-$response = soap_xml_post
-  ('/ws/hello',
-   '<Envelope><Body>World</Body></Envelope>'
-  );
-
-ok($response->content =~ /Hello World/, 'Document Literal correct response: '.$response->content);
-
-$response = soap_xml_post
-  ('/ws2',
-   '<Envelope><Body><hello>World</hello></Body></Envelope>'
-  );
-ok($response->content =~ /Hello World/, 'RPC Literal Correct response: '.$response->content);
-
-$response = soap_xml_post
-  ('/ws/foo',
-   '<Envelope><Body>World</Body></Envelope>'
-  );
-ok($response->content =~ /\<foo\>\<bar\>\<baz\>Hello World\!\<\/baz\>\<\/bar\>\<\/foo\>/, 'Literal response: '.$response->content);
-
-sub soap_xml_post {
-    my $path = shift;
-    my $content = shift;
-
-    local %ENV;
-    $ENV{REMOTE_ADDR} ='127.0.0.1';
-    $ENV{CONTENT_LENGTH} = length $content;
-    $ENV{CONTENT_TYPE} ='application/soap+xml';
-    $ENV{SCRIPT_NAME} = $path;
-    $ENV{QUERY_STRING} = '';
-    $ENV{CATALYST_DEBUG} = 0;
-    $ENV{REQUEST_METHOD} ='POST';
-    $ENV{SERVER_PORT} ='80';
-    $ENV{SERVER_NAME} ='pitombeira';
-
-    my ($writer, $reader, $error) = map { gensym() } 1..3;
-    my $pid = open3($writer, $reader, $error,
-                    $^X, (map { '-I'.$_ } @INC),
-                    catfile(qw(t PostApp script postapp_cgi.pl)));
-
-    print {$writer} $content;
-    close $content;
-
-    my $response_str = join '', <$reader>;
-    map { warn '# '.$_ } <$error>;
-
-    close $reader;
-    close $error;
-    waitpid $pid, 0;
-    return HTTP::Response->parse($response_str);
-}
-
-1;

Copied: Catalyst-Controller-SOAP/1.0/tags/0.2.0/t/PostApp.t (from rev 7390, Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t)
===================================================================
--- Catalyst-Controller-SOAP/1.0/tags/0.2.0/t/PostApp.t	                        (rev 0)
+++ Catalyst-Controller-SOAP/1.0/tags/0.2.0/t/PostApp.t	2008-01-16 12:29:16 UTC (rev 7391)
@@ -0,0 +1,60 @@
+use Test::More tests => 3;
+use File::Spec::Functions;
+use HTTP::Response;
+use IPC::Open3;
+use Symbol;
+
+my $response;
+
+$response = soap_xml_post
+  ('/ws/hello',
+   '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body>World</Body></Envelope>'
+  );
+
+ok($response->content =~ /Hello World/, 'Document Literal correct response: '.$response->content);
+
+$response = soap_xml_post
+  ('/ws2',
+   '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body><hello>World</hello></Body></Envelope>'
+  );
+ok($response->content =~ /Hello World/, 'RPC Literal Correct response: '.$response->content);
+
+$response = soap_xml_post
+  ('/ws/foo',
+   '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body>World</Body></Envelope>'
+  );
+ok($response->content =~ /\<foo\>\<bar\>\<baz\>Hello World\!\<\/baz\>\<\/bar\>\<\/foo\>/, 'Literal response: '.$response->content);
+
+sub soap_xml_post {
+    my $path = shift;
+    my $content = shift;
+
+    local %ENV;
+    $ENV{REMOTE_ADDR} ='127.0.0.1';
+    $ENV{CONTENT_LENGTH} = length $content;
+    $ENV{CONTENT_TYPE} ='application/soap+xml';
+    $ENV{SCRIPT_NAME} = $path;
+    $ENV{QUERY_STRING} = '';
+    $ENV{CATALYST_DEBUG} = 0;
+    $ENV{REQUEST_METHOD} ='POST';
+    $ENV{SERVER_PORT} ='80';
+    $ENV{SERVER_NAME} ='pitombeira';
+
+    my ($writer, $reader, $error) = map { gensym() } 1..3;
+    my $pid = open3($writer, $reader, $error,
+                    $^X, (map { '-I'.$_ } @INC),
+                    catfile(qw(t PostApp script postapp_cgi.pl)));
+
+    print {$writer} $content;
+    close $content;
+
+    my $response_str = join '', <$reader>;
+    map { warn '# '.$_ } <$error>;
+
+    close $reader;
+    close $error;
+    waitpid $pid, 0;
+    return HTTP::Response->parse($response_str);
+}
+
+1;




More information about the Catalyst-commits mailing list