[Catalyst-commits] r7175 - 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
Tue Nov 27 11:03:23 GMT 2007
Author: ruoso
Date: 2007-11-27 11:03:23 +0000 (Tue, 27 Nov 2007)
New Revision: 7175
Modified:
Catalyst-Controller-SOAP/1.0/trunk/Changes
Catalyst-Controller-SOAP/1.0/trunk/MANIFEST
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/WS.pm
Log:
[C-C-SOAP] [git2svn] Thu Nov 22 18:26:32 2007 +0000 -- marking a new release and leaving RPCEncoded out of it.
Modified: Catalyst-Controller-SOAP/1.0/trunk/Changes
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/Changes 2007-11-27 11:02:11 UTC (rev 7174)
+++ Catalyst-Controller-SOAP/1.0/trunk/Changes 2007-11-27 11:03:23 UTC (rev 7175)
@@ -1,9 +1,21 @@
-Revision history for Perl extension Catalyst::Controller::SOAP.
+commit 9303bc1e368afb6def74573941eaf459f58533bc
+Author: Daniel Ruoso <daniel at ruoso.com>
+Date: Wed Nov 21 18:33:13 2007 +0000
-0.01 Tue Nov 6 10:23:19 2007
- - original version; created by h2xs 1.23 with options
- -n Catalyst::Controller::SOAP
+ marking a new release
+commit 9260e5d96945a4edeb07f8676e12750f0d8d6da4
+Author: Daniel Ruoso <daniel at ruoso.com>
+Date: Wed Nov 21 18:32:24 2007 +0000
+
+ Make the test more cross-platform
+
+commit 4089cc6ffd0d2cc90feac824aa39ff593d40aeca
+Author: Daniel Ruoso <daniel at ruoso.com>
+Date: Wed Nov 21 18:23:14 2007 +0000
+
+ Better README and Changes file
+
commit 865fcd5df2222b9034690fef7f4f6c800c9a75d4
Author: Daniel Ruoso <daniel at ruoso.com>
Date: Wed Nov 21 18:21:23 2007 +0000
Modified: Catalyst-Controller-SOAP/1.0/trunk/MANIFEST
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/MANIFEST 2007-11-27 11:02:11 UTC (rev 7174)
+++ Catalyst-Controller-SOAP/1.0/trunk/MANIFEST 2007-11-27 11:03:23 UTC (rev 7175)
@@ -8,15 +8,10 @@
t/lib/TestApp/Controller/WS.pm
t/lib/TestApp/Controller/Root.pm
t/lib/TestApp.pm
-t/PostApp
-t/PostApp/script
t/PostApp/script/postapp_cgi.pl
t/PostApp/script/postapp_test.pl
t/PostApp/script/post.pl
t/PostApp/script/postapp_server.pl
-t/PostApp/lib
-t/PostApp/lib/PostApp
-t/PostApp/lib/PostApp/Controller
t/PostApp/lib/PostApp/Controller/WS.pm
t/PostApp/lib/PostApp/Controller/Root.pm
t/PostApp/lib/PostApp/Controller/WS2.pm
@@ -27,6 +22,5 @@
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
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 11:02:11 UTC (rev 7174)
+++ Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm 2007-11-27 11:03:23 UTC (rev 7175)
@@ -5,7 +5,7 @@
use XML::LibXML;
use constant NS_SOAP_ENV => "http://www.w3.org/2003/05/soap-envelope";
- our $VERSION = '0.0.6';
+ our $VERSION = '0.1';
sub _parse_SOAP_attr {
my ($self, $c, $name, $value) = @_;
@@ -75,6 +75,14 @@
# 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);
+ }
}
}
@@ -107,8 +115,7 @@
use base qw(Class::Accessor::Fast);
__PACKAGE__->mk_accessors(qw{envelope parsed_envelope arguments fault
- encoded_return literal_return
- literal_string_return string_return});
+ encoded_return literal_return string_return});
};
@@ -126,15 +133,10 @@
package MyApp::Controller::Example;
use base 'Catalyst::Controller::SOAP';
- # available in "/example" as operation "echo"
- # parsing the arguments as soap-encoded.
- sub echo : SOAP('RPCEncoded') {
- my ( $self, $c, @args ) = @_;
- }
-
# 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');
@@ -142,13 +144,22 @@
# avaiable as "/example/world" in document context. The entire body
# is delivered to the method as a XML::LibXML object.
- sub world : SOAP('DocumentLiteral') {
- my ($self, $c, $doc) = @_;
+ # 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.
- sub index : SOAP('RPCEndpoint') {}
+ # See Catalyst::Controller::SOAP::RPC.
+ sub index :Local SOAP('RPCEndpoint') {}
=head1 ABSTACT
@@ -161,8 +172,6 @@
controller declares by default an index operation which will dispatch
the RPC operations under this class.
-=back
-
=head1 ATTRIBUTES
This class implements the SOAP attribute wich is used to do the
@@ -212,17 +221,16 @@
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.
+root in the return message or a nodelist.
-=item $c->stash->{soap}->literal_string_return($xml_text)
+Using XML::Compile will help to elaborate schema based returns.
-In this case, the argument is used literally inside the message. It is
-supposed to already contain all namespace definitions in it.
-
=item $c->stash->{soap}->string_return($non_xml_text)
In this case, the given text is encoded as CDATA inside the SOAP
@@ -232,15 +240,25 @@
=head1 TODO
-At this moment, this is a very early release. So 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.
+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<Catalyst::Action::SOAP>, L<XML::LibXML>, L<XML::Compile>
L<Catalyst::Action::SOAP::DocumentLiteral>,
-L<Catalyst::Action::SOAP::RPCEncoded>,
+L<Catalyst::Action::SOAP::RPCLiteral>,
L<Catalyst::Action::SOAP::HTTPGet>
=head1 AUTHORS
Modified: Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WS.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WS.pm 2007-11-27 11:02:11 UTC (rev 7174)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WS.pm 2007-11-27 11:03:23 UTC (rev 7175)
@@ -10,4 +10,19 @@
$c->stash->{soap}->string_return('Hello '.$who.'!');
}
+sub foo : Local SOAP('DocumentLiteral') {
+ my ( $self, $c, $body ) = @_;
+ my $who = $body->textContent();
+
+ my $env = $c->stash->{soap}->parsed_envelope;
+ my $foo = $env->createElement('foo');
+ my $bar = $env->createElement('bar');
+ $foo->appendChild($bar);
+ my $baz = $env->createElement('baz');
+ $bar->appendChild($baz);
+ $baz->appendText('Hello '.$who.'!');
+
+ $c->stash->{soap}->literal_return($foo);
+}
+
1;
Modified: Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t 2007-11-27 11:02:11 UTC (rev 7174)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t 2007-11-27 11:03:23 UTC (rev 7175)
@@ -1,4 +1,4 @@
-use Test::More tests => 2;
+use Test::More tests => 3;
use File::Spec::Functions;
use HTTP::Response;
use IPC::Open3;
@@ -17,9 +17,13 @@
('/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;
More information about the Catalyst-commits
mailing list