[Catalyst-commits] r7565 - in Catalyst-Controller-SOAP/1.0/trunk: lib/Catalyst/Controller t/PostApp/lib/PostApp/Controller

ruoso at dev.catalyst.perl.org ruoso at dev.catalyst.perl.org
Fri Apr 4 21:24:17 BST 2008


Author: ruoso
Date: 2008-04-04 21:24:17 +0100 (Fri, 04 Apr 2008)
New Revision: 7565

Modified:
   Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm
   Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL4.pm
Log:
[C-C-SOAP] FINALLY!!! Automatic RPC endpoint working...

Modified: Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm	2008-04-04 19:42:23 UTC (rev 7564)
+++ Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm	2008-04-04 20:24:17 UTC (rev 7565)
@@ -12,7 +12,7 @@
     our $VERSION = '0.7';
 
     __PACKAGE__->mk_accessors qw(wsdl wsdlobj decoders encoders
-         ports wsdlservice xml_compile soap_action_prefix);
+         ports wsdlservice xml_compile soap_action_prefix rpc_endpoint_paths);
 
     # XXX - This is here as a temporary fix for a bug in _parse_attrs
     # that makes it impossible to return more than one
@@ -24,7 +24,6 @@
         my @others = grep { $_ !~ /^WSDLPort/ } @attrs;
         my $final = $self->SUPER::_parse_attrs($c, $name, @others);
 
-
         my ($attr) = grep { $_ && $_ =~ /^WSDLPort/ } @attrs;
         return $final unless $attr;
 
@@ -109,17 +108,37 @@
                $self->_parse_SOAP_attr($c, $name, $style.$use)
               );
         } else {
-            use Data::Dumper;
-            $self->{actions}{base_rpc_endpoint}{Path} ||= [];
-            push @{$self->{actions}{base_rpc_endpoint}{Path}}, $path
+            $self->rpc_endpoint_paths([]) unless $self->rpc_endpoint_paths;
+            $path =~ s/\/$//;
+            push @{$self->rpc_endpoint_paths}, $path
               unless grep { $_ eq $path }
-                @{$self->{actions}{_base_rpc_endpoint}{Path}};
+                @{$self->rpc_endpoint_paths};
             return $self->_parse_SOAP_attr($c, $name, $style.$use)
         }
     }
 
-    sub base_rpc_endpoint :ActionClass('SOAP::RPCEndpoint') { };
+    # Let's create the rpc_endpoint action.
+    sub register_actions {
+        my $self = shift;
+        my ($c) = @_;
+        $self->SUPER::register_actions(@_);
 
+        if ($self->rpc_endpoint_paths) {
+            my $namespace = $self->action_namespace($c);
+            my $action = $self->create_action
+              (
+               name => 'base_rpc_endpoint',
+               code => sub { },
+               reverse => ($namespace ? $namespace.'/' : '') . 'base_rpc_endpoint',
+               namespace => $namespace,
+               class => (ref $self || $self),
+               attributes => { ActionClass => [ 'Catalyst::Action::SOAP::RPCEndpoint' ],
+                               Path => $self->rpc_endpoint_paths }
+              );
+            $c->dispatcher->register($c, $action);
+        }
+    }
+
     sub _parse_SOAP_attr {
         my ($self, $c, $name, $value) = @_;
 

Modified: Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL4.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL4.pm	2008-04-04 19:42:23 UTC (rev 7564)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL4.pm	2008-04-04 20:24:17 UTC (rev 7565)
@@ -10,14 +10,14 @@
     my ( $self, $c, $args ) = @_;
     my $who = $args->{who};
     my $grt = $args->{greeting};
-    $c->stash->{soap}->compile_return({ $grt.' '.$who.'!' });
+    $c->stash->{soap}->compile_return({ greeting => $grt.' '.$who.'!' });
 }
 
 sub Shout : WSDLPort('Greet') {
     my ( $self, $c, $args ) = @_;
     my $who = $args->{who};
     my $grt = $args->{greeting};
-    $c->stash->{soap}->compile_return({ uc($grt).' '.uc($who).'!' });
+    $c->stash->{soap}->compile_return({ greeting => uc($grt).' '.uc($who).'!' });
 }
 
 1;




More information about the Catalyst-commits mailing list