[Catalyst-commits] r7563 - in Catalyst-Controller-SOAP/1.0/trunk:
lib/Catalyst/Action/SOAP lib/Catalyst/Controller
lib/Catalyst/Controller/SOAP t t/PostApp/lib/PostApp/Controller
ruoso at dev.catalyst.perl.org
ruoso at dev.catalyst.perl.org
Fri Apr 4 20:41:33 BST 2008
Author: ruoso
Date: 2008-04-04 20:41:33 +0100 (Fri, 04 Apr 2008)
New Revision: 7563
Added:
Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL4.pm
Catalyst-Controller-SOAP/1.0/trunk/t/hello4.wsdl
Modified:
Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/DocumentLiteralWrapped.pm
Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm
Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP/RPC.pm
Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t
Log:
[C-C-SOAP] config usage cleanup.
Modified: Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/DocumentLiteralWrapped.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/DocumentLiteralWrapped.pm 2008-04-04 18:04:56 UTC (rev 7562)
+++ Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Action/SOAP/DocumentLiteralWrapped.pm 2008-04-04 19:41:33 UTC (rev 7563)
@@ -8,7 +8,7 @@
$self->prepare_soap_helper(@_);
- my $prefix = $controller->config->{soap_action_prefix};
+ my $prefix = $controller->soap_action_prefix;
my $soapaction = $c->req->headers->header('SOAPAction');
die 'No SOAP Action' unless $soapaction;
Modified: Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP/RPC.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP/RPC.pm 2008-04-04 18:04:56 UTC (rev 7562)
+++ Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP/RPC.pm 2008-04-04 19:41:33 UTC (rev 7563)
@@ -1,7 +1,7 @@
{ package Catalyst::Controller::SOAP::RPC;
use strict;
use base qw(Catalyst::Controller::SOAP);
- sub rpc_endpoint :Path('') :ActionClass('SOAP::RPCEndpoint') { };
+ sub rpc_endpoint :Path('') :ActionClass('SOAP::RPCEndpoint') {};
};
1;
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 18:04:56 UTC (rev 7562)
+++ Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm 2008-04-04 19:41:33 UTC (rev 7563)
@@ -11,9 +11,13 @@
our $VERSION = '0.7';
- __PACKAGE__->mk_accessors qw(wsdlobj decoders encoders ports);
+ __PACKAGE__->mk_accessors qw(wsdl wsdlobj decoders encoders
+ ports wsdlservice xml_compile soap_action_prefix);
- # XXX - This is here as a temporary fix for
+ # XXX - This is here as a temporary fix for a bug in _parse_attrs
+ # that makes it impossible to return more than one
+ # "final_attribute", a patch was already submitted and should make
+ # into the next release.
sub _parse_attrs {
my ( $self, $c, $name, @attrs ) = @_;
@@ -24,7 +28,7 @@
my ($attr) = grep { $_ && $_ =~ /^WSDLPort/ } @attrs;
return $final unless $attr;
- if ( my ( $key, $value ) = ( $attr =~ /^(.*?)(?:\(\s*(.+?)\s*\))?$/ ) ) #* emacs bug
+ if ( my ( $key, $value ) = ( $attr =~ /^(.*?)(?:\(\s*(.+?)\s*\))?$/ ) )
{
if ( defined $value ) {
( $value =~ s/^'(.*)'$/$1/ ) || ( $value =~ s/^"(.*)"/$1/ );
@@ -42,7 +46,7 @@
sub __init_wsdlobj {
my ($self, $c) = @_;
- my $wsdlfile = $self->config->{wsdl};
+ my $wsdlfile = $self->wsdl;
if ($wsdlfile) {
if (!$self->wsdlobj) {
@@ -81,7 +85,7 @@
$self->ports->{$name} = $value;
my $operation = $self->wsdlobj->operation($name,
port => $value,
- service => $self->config->{wsdlservice})
+ service => $self->wsdlservice)
or die 'Every operation should be on the WSDL when using one.';
# TODO: Use more intelligence when selecting the address.
@@ -99,22 +103,29 @@
$use = $use =~ /literal/i ? 'Literal' : 'Encoded';
if ($style eq 'Document') {
- return
- (
- Path => $path,
- $self->_parse_SOAP_attr($c, $name, $style.$use)
- )
+ return
+ (
+ Path => $path,
+ $self->_parse_SOAP_attr($c, $name, $style.$use)
+ );
} else {
- return $self->_parse_SOAP_attr($c, $name, $style.$use)
+ use Data::Dumper;
+ $self->{actions}{_base_rpc_endpoint}{Path} ||= [];
+ push @{$self->{actions}{_base_rpc_endpoint}{Path}}, $path
+ unless grep { $_ eq $path }
+ @{$self->{actions}{_base_rpc_endpoint}{Path}};
+ return $self->_parse_SOAP_attr($c, $name, $style.$use)
}
}
+ sub _base_rpc_endpoint :ActionClass('SOAP::RPCEndpoint') { };
+
sub _parse_SOAP_attr {
my ($self, $c, $name, $value) = @_;
- my $wsdlfile = $self->config->{wsdl};
- my $wsdlservice = $self->config->{wsdl_service};
- my $compile_opts = $self->config->{xml_compile} || {};
+ my $wsdlfile = $self->wsdl;
+ my $wsdlservice = $self->wsdlservice;
+ my $compile_opts = $self->xml_compile || {};
$compile_opts->{reader} ||= {};
$compile_opts->{writer} ||= {};
@@ -293,6 +304,7 @@
};
+
1;
__END__
Added: 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 (rev 0)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL4.pm 2008-04-04 19:41:33 UTC (rev 7563)
@@ -0,0 +1,23 @@
+package PostApp::Controller::WithWSDL4;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller::SOAP::RPC';
+
+__PACKAGE__->config->{wsdl} = 't/hello4.wsdl';
+
+sub Greet : WSDLPort('Greet') {
+ my ( $self, $c, $args ) = @_;
+ my $who = $args->{who};
+ my $grt = $args->{greeting};
+ $c->stash->{soap}->compile_return({ $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).'!' });
+}
+
+1;
Modified: Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t 2008-04-04 18:04:56 UTC (rev 7562)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t 2008-04-04 19:41:33 UTC (rev 7563)
@@ -1,4 +1,4 @@
-use Test::More tests => 11;
+use Test::More tests => 13;
use File::Spec::Functions;
use HTTP::Response;
use IPC::Open3;
@@ -116,6 +116,21 @@
# diag("/withwsdl/Shout: ".$response->content);
+$response = soap_xml_post
+ ('/rpcliteral','
+ <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body><Greet><who>World</who><greeting>Hello</greeting></Greet></Body></Envelope>
+ ');
+like($response->content, qr/greeting[^>]+\>Hello World\!\<\//, ' WSDLPort RPC Literal response: '.$response->content);
+# diag("/withwsdl2/Greet: ".$response->content);
+
+$response = soap_xml_post
+ ('/rpcliteral','
+ <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body><Shout><who>World</who><greeting>Hello</greeting></Shout></Body></Envelope>
+ ');
+like($response->content, qr/greeting[^>]+\>HELLO WORLD\!\<\//, ' WSDLPort RPC Literal response: '.$response->content);
+# diag("/withwsdl2/Greet: ".$response->content);
+
+
sub soap_xml_post {
my $path = shift;
my $content = shift;
Added: Catalyst-Controller-SOAP/1.0/trunk/t/hello4.wsdl
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/hello4.wsdl (rev 0)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/hello4.wsdl 2008-04-04 19:41:33 UTC (rev 7563)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:s="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:hello="http://example.com/hello"
+ xmlns="http://example.com/hello"
+ targetNamespace="http://example.com/hello">
+
+ <wsdl:types>
+ <s:schema elementFormDefault="qualified" targetNamespace="http://example.com/hello">
+ <s:element minOccurs="0" maxOccurs="1" name="who" type="s:string"/>
+ <s:element minOccurs="0" maxOccurs="1" name="greeting" type="s:string"/>
+ </s:schema>
+ </wsdl:types>
+ <wsdl:message name="AskGreeting">
+ <wsdl:part name="who" element="hello:who"/>
+ <wsdl:part name="greeting" element="hello:greeting"/>
+ </wsdl:message>
+ <wsdl:message name="GiveGreeting">
+ <wsdl:part name="greeting" element="hello:greeting"/>
+ </wsdl:message>
+ <wsdl:portType name="Greeting">
+ <wsdl:operation name="Greet">
+ <wsdl:input message="hello:AskGreeting"/>
+ <wsdl:output message="hello:GiveGreeting"/>
+ </wsdl:operation>
+ <wsdl:operation name="Shout">
+ <wsdl:input message="hello:AskGreeting"/>
+ <wsdl:output message="hello:GiveGreeting"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="Greeting" type="hello:Greeting">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
+ <wsdl:operation name="Greet">
+ <soap:operation soapAction="http://example.com/" />
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="Shout">
+ <soap:operation soapAction="http://example.com/" />
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="GreetService">
+ <wsdl:port name="Greet" binding="hello:Greeting">
+ <soap:address location="http://localhost:3000/rpcliteral/"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file
More information about the Catalyst-commits
mailing list