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

ruoso at dev.catalyst.perl.org ruoso at dev.catalyst.perl.org
Fri Jun 5 19:50:53 GMT 2009


Author: ruoso
Date: 2009-06-05 19:50:53 +0000 (Fri, 05 Jun 2009)
New Revision: 10433

Modified:
   Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm
   Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t
   Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL4.pm
   Catalyst-Controller-SOAP/1.0/trunk/t/hello4.wsdl
Log:
[C-C-SOAP] Dont provide any return when no return is expected

Modified: Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm	2009-06-05 08:34:43 UTC (rev 10432)
+++ Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm	2009-06-05 19:50:53 UTC (rev 10433)
@@ -293,7 +293,8 @@
         my ($self, $c) = (shift, shift);
         my $soap = $c->stash->{soap};
 
-        return $self->maybe::next::method($c, @_) unless $soap;
+        return $self->maybe::next::method($c, @_)
+          unless $soap;
 
         if (scalar @{$c->error}) {
             $c->stash->{soap}->fault
@@ -354,18 +355,18 @@
                 $text->appendText($soap->fault->{detail});
             }
         } else {
-            $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->string_return) {
+                $envelope = $response->createElementNS(NS_SOAP_ENV, "Envelope");
+                $response->setDocumentElement($envelope);
+                my $body = $response->createElementNS(NS_SOAP_ENV, "Body");
+                $envelope->appendChild($body);
                 $body->appendText($soap->string_return);
             } elsif (my $lit = $soap->literal_return) {
+                $envelope = $response->createElementNS(NS_SOAP_ENV, "Envelope");
+                $response->setDocumentElement($envelope);
+                my $body = $response->createElementNS(NS_SOAP_ENV, "Body");
+                $envelope->appendChild($body);
                 if (ref $lit eq 'XML::LibXML::NodeList') {
                     for ($lit->get_nodelist) {
                         $body->appendChild($_);
@@ -374,6 +375,10 @@
                     $body->appendChild($lit);
                 }
             } elsif (my $cmp = $soap->compile_return) {
+                $envelope = $response->createElementNS(NS_SOAP_ENV, "Envelope");
+                $response->setDocumentElement($envelope);
+                my $body = $response->createElementNS(NS_SOAP_ENV, "Body");
+                $envelope->appendChild($body);
                 die 'Tried to use compile_return without WSDL'
                   unless $self->wsdlobj;
 
@@ -383,10 +388,14 @@
             }
         }
 
-        $c->res->status(500) if $soap->fault;
-        $c->log->debug("Outgoing XML: ".$envelope->toString()) if $c->debug;
-        $c->res->content_type('text/xml; charset=UTF-8');
-        $c->res->body(encode('utf8',$envelope->toString()));
+        if ($envelope) {
+          $c->res->status(500) if $soap->fault;
+          $c->log->debug("Outgoing XML: ".$envelope->toString()) if $c->debug;
+          $c->res->content_type('text/xml; charset=UTF-8');
+          $c->res->body(encode('utf8',$envelope->toString()));
+        } else {
+          $c->maybe::next::method($c, @_);
+        }
     }
 
 

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	2009-06-05 08:34:43 UTC (rev 10432)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL4.pm	2009-06-05 19:50:53 UTC (rev 10433)
@@ -20,4 +20,11 @@
     $c->stash->{soap}->compile_return({ greeting => uc($grt).' '.uc($who).'!' });
 }
 
+sub Blag : WSDLPort('Greet') {
+    my ( $self, $c, $args ) = @_;
+    my $who = $args->{who};
+    my $grt = $args->{greeting};
+    $c->res->body($grt);
+}
+
 1;

Modified: Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t	2009-06-05 08:34:43 UTC (rev 10432)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t	2009-06-05 19:50:53 UTC (rev 10433)
@@ -1,4 +1,4 @@
-use Test::More tests => 14;
+use Test::More tests => 15;
 use File::Spec::Functions;
 use HTTP::Response;
 use IPC::Open3;
@@ -136,6 +136,12 @@
 my $soapfault = 'Fault'; 
 ok($response->content =~ /$soapfault/ , ' SOAP Fault response: '.$response->content);
 
+$response = soap_xml_post
+  ('/rpcliteral','
+    <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body><Blag xmlns="http://example.com/hello"><who>World</who><greeting>ok 15</greeting></Blag></Body></Envelope>
+  ');
+is($response->content, 'ok 15');
+
 sub soap_xml_post {
     my $path = shift;
     my $content = shift;
@@ -146,7 +152,7 @@
     $ENV{CONTENT_TYPE} ='application/soap+xml';
     $ENV{SCRIPT_NAME} = $path;
     $ENV{QUERY_STRING} = '';
-    $ENV{CATALYST_DEBUG} = 0;
+    $ENV{CATALYST_DEBUG} = 1;
     $ENV{REQUEST_METHOD} ='POST';
     $ENV{SERVER_PORT} ='80';
     $ENV{SERVER_NAME} ='pitombeira';

Modified: Catalyst-Controller-SOAP/1.0/trunk/t/hello4.wsdl
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/hello4.wsdl	2009-06-05 08:34:43 UTC (rev 10432)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/hello4.wsdl	2009-06-05 19:50:53 UTC (rev 10433)
@@ -30,6 +30,9 @@
       <wsdl:input message="hello:AskGreeting"/>
       <wsdl:output message="hello:GiveGreeting"/>
     </wsdl:operation>
+    <wsdl:operation name="Blag">
+      <wsdl:input message="hello:AskGreeting"/>
+    </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="Greeting" type="hello:Greeting">
     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
@@ -51,6 +54,12 @@
         <soap:body use="literal" namespace="http://example.com/hello"/>
       </wsdl:output>
     </wsdl:operation>
+    <wsdl:operation name="Blag">
+      <soap:operation soapAction="http://example.com/" />
+      <wsdl:input>
+        <soap:body use="literal" namespace="http://example.com/hello"/>
+      </wsdl:input>
+    </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="GreetService">
     <wsdl:port name="Greet" binding="hello:Greeting">




More information about the Catalyst-commits mailing list