[Catalyst-commits] r7390 - in Catalyst-Controller-SOAP/1.0/trunk:
lib/Catalyst/Action/SOAP lib/Catalyst/Controller t
ruoso at dev.catalyst.perl.org
ruoso at dev.catalyst.perl.org
Wed Jan 16 12:28:39 GMT 2008
Author: ruoso
Date: 2008-01-16 12:28:39 +0000 (Wed, 16 Jan 2008)
New Revision: 7390
Modified:
Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/DocumentLiteral.pm
Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/RPCEndpoint.pm
Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm
Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t
Log:
[C-C-SOAP] some fixes thanks to kaare++
Modified: Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/DocumentLiteral.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/DocumentLiteral.pm 2008-01-16 10:33:44 UTC (rev 7389)
+++ Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/DocumentLiteral.pm 2008-01-16 12:28:39 UTC (rev 7390)
@@ -1,7 +1,7 @@
{ package Catalyst::Action::SOAP::DocumentLiteral;
use base qw/Catalyst::Action::SOAP/;
- use constant NS_SOAP_ENV => "http://www.w3.org/2003/05/soap-envelope";
+ use constant NS_SOAP_ENV => "http://schemas.xmlsoap.org/soap/envelope/";
sub execute {
my $self = shift;
@@ -10,7 +10,8 @@
$self->prepare_soap_xml_post($c);
unless ($c->stash->{soap}->fault) {
my $envelope = $c->stash->{soap}->parsed_envelope;
- my ($body) = $envelope->getElementsByTagNameNS(NS_SOAP_ENV, 'Body');
+ my $namespace = $c->stash->{soap}->namespace || NS_SOAP_ENV;
+ my ($body) = $envelope->getElementsByTagNameNS($namespace, 'Body');
$self->NEXT::execute($controller, $c, $body);
}
}
Modified: Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/RPCEndpoint.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/RPCEndpoint.pm 2008-01-16 10:33:44 UTC (rev 7389)
+++ Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/RPCEndpoint.pm 2008-01-16 12:28:39 UTC (rev 7390)
@@ -1,7 +1,7 @@
{ package Catalyst::Action::SOAP::RPCEndpoint;
use base qw/Catalyst::Action::SOAP/;
- use constant NS_SOAP_ENV => "http://www.w3.org/2003/05/soap-envelope";
+ use constant NS_SOAP_ENV => "http://schemas.xmlsoap.org/soap/envelope/";
sub execute {
my $self = shift;
@@ -11,7 +11,8 @@
$self->prepare_soap_xml_post($c);
unless ($c->stash->{soap}->fault) {
my $envelope = $c->stash->{soap}->parsed_envelope;
- my ($body) = $envelope->getElementsByTagNameNS(NS_SOAP_ENV,'Body',0);
+ 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
@@ -19,7 +20,10 @@
reason => 'Bad Body', detail =>
'RPC messages should contain only one element inside body'})
} else {
- my $operation = $children[0]->nodeName();
+ 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}}) {
Modified: Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm 2008-01-16 10:33:44 UTC (rev 7389)
+++ Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm 2008-01-16 12:28:39 UTC (rev 7390)
@@ -4,9 +4,10 @@
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.2';
+ 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 :
@@ -24,48 +25,49 @@
return $self->NEXT::end($c, @_) unless $soap;
+ my $namespace = $soap->namespace || NS_SOAP_ENV;
my $response = XML::LibXML->createDocument();
my $envelope = $response->createElementNS
- (NS_SOAP_ENV,"Envelope");
+ ($namespace,"Envelope");
$response->setDocumentElement($envelope);
# TODO: we don't support header generation in response yet.
my $body = $response->createElementNS
- (NS_SOAP_ENV,"Body");
+ ($namespace,"Body");
$envelope->appendChild($body);
if ($soap->fault) {
my $fault = $response->createElementNS
- (NS_SOAP_ENV, "Fault");
+ ($namespace, "Fault");
$body->appendChild($fault);
my $code = $response->createElementNS
- (NS_SOAP_ENV, "Code");
+ ($namespace, "Code");
$fault->appendChild($code);
- $self->_generate_Fault_Code($response,$code,$soap->fault->{code});
+ $self->_generate_Fault_Code($response,$code,$soap->fault->{code}, $namespace);
if ($soap->fault->{reason}) {
my $reason = $response->createElementNS
- (NS_SOAP_ENV, "Reason");
+ ($namespace, "Reason");
$fault->appendChild($reason);
# TODO: we don't support the xml:lang attribute yet.
my $text = $response->createElementNS
- (NS_SOAP_ENV, "Text");
+ ($namespace, "Text");
$reason->appendChild($text);
$text->appendText($soap->fault->{reason});
}
if ($soap->fault->{detail}) {
my $detail = $response->createElementNS
- (NS_SOAP_ENV, "Detail");
+ ($namespace, "Detail");
$fault->appendChild($detail);
# TODO: we don't support the xml:lang attribute yet.
my $text = $response->createElementNS
- (NS_SOAP_ENV, "Text");
+ ($namespace, "Text");
$detail->appendChild($text);
$text->appendText($soap->fault->{detail});
}
@@ -86,21 +88,22 @@
}
}
+ $c->res->content_type('text/xml');
$c->res->body($envelope->toString());
}
sub _generate_Fault_Code {
- my ($self, $document, $codenode, $codeValue) = @_;
+ my ($self, $document, $codenode, $codeValue, $namespace) = @_;
my $value = $document->createElementNS
- (NS_SOAP_ENV, "Value");
+ ($namespace, "Value");
if (ref $codeValue eq 'ARRAY') {
$value->appendText($codeValue->[0]);
my $subcode = $document->createElementNS
- (NS_SOAP_ENV, 'SubCode');
+ ($namespace, 'SubCode');
$codenode->appendChild($value);
$codenode->appendChild($subcode);
- $self->_generate_Fault_Code($document, $subcode, $codeValue->[1]);
+ $self->_generate_Fault_Code($document, $subcode, $codeValue->[1], $namespace);
} else {
$value->appendText($codeValue);
$codenode->appendChild($value);
@@ -114,7 +117,7 @@
use base qw(Class::Accessor::Fast);
- __PACKAGE__->mk_accessors(qw{envelope parsed_envelope arguments fault
+ __PACKAGE__->mk_accessors(qw{envelope parsed_envelope arguments fault namespace
encoded_return literal_return string_return});
Modified: Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t 2008-01-16 10:33:44 UTC (rev 7389)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t 2008-01-16 12:28:39 UTC (rev 7390)
@@ -8,20 +8,20 @@
$response = soap_xml_post
('/ws/hello',
- '<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope"><Body>World</Body></Envelope>'
+ '<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://www.w3.org/2003/05/soap-envelope"><Body><hello>World</hello></Body></Envelope>'
+ '<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://www.w3.org/2003/05/soap-envelope"><Body>World</Body></Envelope>'
+ '<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);
More information about the Catalyst-commits
mailing list