[Catalyst-commits] r7552 - in Catalyst-Controller-SOAP/1.0/trunk: .
lib/Catalyst/Controller t t/PostApp/lib/PostApp/Controller
drew at dev.catalyst.perl.org
drew at dev.catalyst.perl.org
Fri Apr 4 01:20:54 BST 2008
Author: drew
Date: 2008-04-04 01:20:54 +0100 (Fri, 04 Apr 2008)
New Revision: 7552
Modified:
Catalyst-Controller-SOAP/1.0/trunk/README
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/WithWSDL.pm
Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL2.pm
Catalyst-Controller-SOAP/1.0/trunk/t/hello.wsdl
Catalyst-Controller-SOAP/1.0/trunk/t/hello2.wsdl
Log:
Added support for passing options to $wsdl->schemas->compile().
Modified: Catalyst-Controller-SOAP/1.0/trunk/README
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/README 2008-04-02 15:16:37 UTC (rev 7551)
+++ Catalyst-Controller-SOAP/1.0/trunk/README 2008-04-04 00:20:54 UTC (rev 7552)
@@ -103,6 +103,7 @@
AUTHORS
Daniel Ruoso "daniel.ruoso at verticalone.pt"
+ Drew Taylor "drew at drewtaylor.com"
BUG REPORTS
Please submit all bugs regarding "Catalyst::Controller::SOAP" to
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-02 15:16:37 UTC (rev 7551)
+++ Catalyst-Controller-SOAP/1.0/trunk/lib/Catalyst/Controller/SOAP.pm 2008-04-04 00:20:54 UTC (rev 7552)
@@ -16,6 +16,10 @@
my ($self, $c, $name, $value) = @_;
my $wsdlfile = $self->config->{wsdl};
+ my $compile_opts = $self->config->{xml_compile} || {};
+ $compile_opts->{reader} ||= {};
+ $compile_opts->{writer} ||= {};
+
if ($wsdlfile) {
if (!$self->wsdlobj) {
my $schema;
@@ -45,7 +49,7 @@
my $input_parts = $self->wsdlobj->find(message => $portop->{input}{message})
->{part};
- $_->{compiled} = $self->wsdlobj->schemas->compile(READER => $_->{element})
+ $_->{compiled} = $self->wsdlobj->schemas->compile(READER => $_->{element}, %{$compile_opts->{reader}})
for @{$input_parts};
$self->decoders({}) unless $self->decoders();
@@ -63,7 +67,7 @@
my $output_parts = $self->wsdlobj->find(message => $portop->{output}{message})
->{part};
- $_->{compiled} = $self->wsdlobj->schemas->compile(WRITER => $_->{element})
+ $_->{compiled} = $self->wsdlobj->schemas->compile(WRITER => $_->{element}, %{$compile_opts->{writer}})
for @{$output_parts};
$self->encoders({}) unless $self->encoders();
@@ -349,6 +353,16 @@
In this case, the given structure will be transformed by XML::Compile,
according to what's described in the WSDL file.
+If you define "xml_compile" as a configuration key (which is a
+hashref with keys 'reader' and 'writer', which both have a hashref
+as their value), those key / value pairs will be passed as options
+to the XML::Compile::Schema::compile() method.
+
+ __PACKAGE__->config->{xml_compile} = {
+ reader => {sloppy_integers => 1},
+ writer => {sloppy_integers => 1},
+ };
+
=back
=head1 TODO
Modified: Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL.pm 2008-04-02 15:16:37 UTC (rev 7551)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL.pm 2008-04-04 00:20:54 UTC (rev 7552)
@@ -6,12 +6,17 @@
__PACKAGE__->config->{wsdl} = 't/hello.wsdl';
__PACKAGE__->config->{soap_action_prefix} = 'http://example.com/actions/';
+__PACKAGE__->config->{xml_compile} = {
+ reader => {sloppy_integers => 1},
+ writer => {sloppy_integers => 1},
+};
sub Greet : Local SOAP('DocumentLiteral') {
my ( $self, $c, $args ) = @_;
my $who = $args->{parameters}{who};
my $grt = $args->{parameters}{greeting};
- $c->stash->{soap}->compile_return({ details => { greeting => $grt.' '.$who.'!' }});
+ my $num = $args->{parameters}{count};
+ $c->stash->{soap}->compile_return({ details => { greeting => $num.' '.$grt.' '.$who.'!'.(ref $num||'') }});
}
sub doclw : Local ActionClass('SOAP::DocumentLiteralWrapped') { }
Modified: Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL2.pm
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL2.pm 2008-04-02 15:16:37 UTC (rev 7551)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/PostApp/lib/PostApp/Controller/WithWSDL2.pm 2008-04-04 00:20:54 UTC (rev 7552)
@@ -5,12 +5,17 @@
use base 'Catalyst::Controller::SOAP::RPC';
__PACKAGE__->config->{wsdl} = 't/hello2.wsdl';
+__PACKAGE__->config->{xml_compile} = {
+ # reader => {sloppy_integers => 1},
+ # writer => {sloppy_integers => 1},
+};
sub Greet : SOAP('RPCLiteral') {
my ( $self, $c, $args ) = @_;
my $who = $args->{who};
my $grt = $args->{greeting};
- $c->stash->{soap}->compile_return({ greeting => $grt.' '.$who.'!' });
+ my $num = $args->{count};
+ $c->stash->{soap}->compile_return({ greeting => $num.' '.$grt.' '.$who.'!'.(ref $num||'') });
}
1;
Modified: Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t 2008-04-02 15:16:37 UTC (rev 7551)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/PostApp.t 2008-04-04 00:20:54 UTC (rev 7552)
@@ -11,44 +11,52 @@
'<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body>World</Body></Envelope>'
);
-ok($response->content =~ /Hello World/, 'Document Literal correct response: '.$response->content);
+like($response->content, qr/Hello World/, 'Document Literal correct response: '.$response->content);
+# diag("/ws/hello: ".$response->content);
$response = soap_xml_post
('/ws2',
'<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);
+like($response->content, qr/Hello World/, 'RPC Literal Correct response: '.$response->content);
+# diag("/ws2: ".$response->content);
$response = soap_xml_post
('/ws/foo',
'<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);
+like($response->content, qr/\<foo\>\<bar\>\<baz\>Hello World\!\<\/baz\>\<\/bar\>\<\/foo\>/, 'Literal response: '.$response->content);
+# diag("/wsl/foo: ".$response->content);
$response = soap_xml_post
('/withwsdl/Greet',
- '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body><GreetingSpecifier><who>World</who><greeting>Hello</greeting></GreetingSpecifier></Body></Envelope>'
+ '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
+ <Body>
+ <GreetingSpecifier>
+ <who>World</who>
+ <greeting>Hello</greeting>
+ <count>1</count>
+ </GreetingSpecifier>
+ </Body>
+ </Envelope>'
);
-ok($response->content =~ /greeting\>Hello World\!\<\//, 'Literal response: '.$response->content);
+like($response->content, qr/greeting\>1 Hello World\!\<\//, 'Literal response: '.$response->content);
+# diag("/withwsdl/Greet: ".$response->content);
+
$response = soap_xml_post
('/withwsdl/doclw',
- '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body><GreetingSpecifier><who>World</who><greeting>Hello</greeting></GreetingSpecifier></Body></Envelope>'
+ '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body><GreetingSpecifier><who>World</who><greeting>Hello</greeting><count>2</count></GreetingSpecifier></Body></Envelope>'
);
-ok($response->content =~ /greeting\>Hello World\!\<\//, ' Document/Literal Wrapped response: '.$response->content);
+like($response->content, qr/greeting\>2 Hello World\!\<\//, ' Document/Literal Wrapped response: '.$response->content);
+# diag("/withwsdl/doclw: ".$response->content);
$response = soap_xml_post
('/withwsdl2/Greet','
- <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
- <Body>
- <Greet>
- <who>World</who>
- <greeting>Hello</greeting>
- </Greet>
- </Body>
- </Envelope>
+ <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body><Greet><who>World</who><greeting>Hello</greeting><count>3</count></Greet></Body></Envelope>
');
-ok($response->content =~ /greeting[^>]+\>Hello World\!\<\//, 'Literal response: '.$response->content);
+like($response->content, qr/greeting[^>]+\>3 Hello World\!Math::BigInt\<\//, 'RPC Literal response: '.$response->content);
+# diag("/withwsdl2/Greet: ".$response->content);
$response = soap_xml_post
('/withwsdl2/Greet','
@@ -57,27 +65,29 @@
<Greet>
<who>World</who>
<greeting>Hello</greeting>
+ <count>4</count>
</Greet>
</Body>
</Envelope>
');
-ok($response->content =~ /greeting[^>]+\>Hello World\!\<\//, 'Literal response: '.$response->content);
+ok($response->content =~ /greeting[^>]+\>4 Hello World\!Math::BigInt\<\//, 'RPC Literal response: '.$response->content);
+# diag("/withwsdl2/Greet: ".$response->content);
-
$response = soap_xml_post
('/withwsdl/Greet',
'<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body><GreetingSpecifier><name>World</name><greeting>Hello</greeting></GreetingSpecifier></Body></Envelope>'
);
-ok($response->content =~ /Fault/, 'Fault on malformed body for Document-Literal: '.$response->content);
+like($response->content, qr/Fault/, 'Fault on malformed body for Document-Literal: '.$response->content);
+# diag("/withwsdl/Greet: ".$response->content);
$response = soap_xml_post
('/ws/bar',
'<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body>World</Body></Envelope>'
);
-ok($response->content =~ /Fault/, 'Fault for uncaugh exception: '.$response->content);
+like($response->content, qr/Fault/, 'Fault for uncaugh exception: '.$response->content);
+# diag("/ws/bar: ".$response->content);
-
sub soap_xml_post {
my $path = shift;
my $content = shift;
Modified: Catalyst-Controller-SOAP/1.0/trunk/t/hello.wsdl
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/hello.wsdl 2008-04-02 15:16:37 UTC (rev 7551)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/hello.wsdl 2008-04-04 00:20:54 UTC (rev 7552)
@@ -15,6 +15,7 @@
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="who" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="greeting" type="s:string"/>
+ <s:element minOccurs="0" maxOccurs="1" name="count" type="s:integer"/>
</s:sequence>
</s:complexType>
</s:element>
Modified: Catalyst-Controller-SOAP/1.0/trunk/t/hello2.wsdl
===================================================================
--- Catalyst-Controller-SOAP/1.0/trunk/t/hello2.wsdl 2008-04-02 15:16:37 UTC (rev 7551)
+++ Catalyst-Controller-SOAP/1.0/trunk/t/hello2.wsdl 2008-04-04 00:20:54 UTC (rev 7552)
@@ -12,11 +12,13 @@
<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:element minOccurs="0" maxOccurs="1" name="count" type="s:integer"/>
</s:schema>
</wsdl:types>
<wsdl:message name="AskGreeting">
<wsdl:part name="who" element="hello:who"/>
<wsdl:part name="greeting" element="hello:greeting"/>
+ <wsdl:part name="count" element="hello:count"/>
</wsdl:message>
<wsdl:message name="GiveGreeting">
<wsdl:part name="greeting" element="hello:greeting"/>
More information about the Catalyst-commits
mailing list