[Catalyst-commits] r7679 - Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model

ruoso at dev.catalyst.perl.org ruoso at dev.catalyst.perl.org
Mon May 5 21:03:56 BST 2008


Author: ruoso
Date: 2008-05-05 21:03:56 +0100 (Mon, 05 May 2008)
New Revision: 7679

Modified:
   Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model/SOAP.pm
Log:
[C-M-SOAP] QNames can be declared without prefix. Providing quick fix here while it is not applied to XML::Compile::Schema;:BuiltInTypes

Modified: Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model/SOAP.pm
===================================================================
--- Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model/SOAP.pm	2008-05-05 20:02:01 UTC (rev 7678)
+++ Catalyst-Model-SOAP/1.0/trunk/lib/Catalyst/Model/SOAP.pm	2008-05-05 20:03:56 UTC (rev 7679)
@@ -2,10 +2,12 @@
     use strict;
     use warnings;
     use XML::Compile::WSDL11;
+    use XML::Compile::Util qw/pack_type/;
     use List::Util qw/first/;
     use base qw(Catalyst::Model);
     our $VERSION = '0.0.6';
 
+
     __PACKAGE__->mk_accessors('transport');
 
     use constant NS_SOAP_ENV => "http://schemas.xmlsoap.org/soap/envelope/";
@@ -114,12 +116,7 @@
             for (@{$input_parts}) {
                 my $type = $_->{type} ? $_->{type} : $_->{element};
                 $_->{compiled_writer} = $wsdl_obj->schemas->compile
-                  (WRITER => $type, elements_qualified => 'ALL',
-                   output_namespaces =>
-                   {NS_SOAP_ENV =>
-                    { uri => NS_SOAP_ENV,
-                      prefix => 'SOAPENV',
-                      used => 1 }});
+                  (WRITER => $type, elements_qualified => 'ALL');
             };
 
             my $output_parts = $wsdl_obj->find(message => $portop->{output}{message})
@@ -127,12 +124,7 @@
             for (@{$output_parts}) {
                 my $type = $_->{type} ? $_->{type} : $_->{element};
                 $_->{compiled_reader} = $wsdl_obj->schemas->compile
-                  (READER => $type,
-                   output_namespaces =>
-                   {NS_SOAP_ENV =>
-                    { uri => NS_SOAP_ENV,
-                      prefix => 'SOAPENV',
-                      used => 1 }});
+                  (READER => $type);
             }
 
             $rpcin = sub {
@@ -179,6 +171,31 @@
     use warnings;
     use base qw(Catalyst::Model);
 }
+
+
+{   use XML::Compile::Schema::BuiltInTypes;
+    package XML::Compile::Schema::BuiltInTypes;
+
+    $XML::Compile::Schema::BuiltInTypes::builtin_types{QName}{parse} =
+     sub { my ($qname, $node) = @_;
+           my $prefix = $qname =~ s/^([^:]*)\:// ? $1 : '';
+
+           $node = $node->node if $node->isa('XML::Compile::Iterator');
+
+           unless ($prefix) {
+               return pack_type($node->namespaceURI, $qname);
+           }
+
+           my $ns = $node->lookupNamespaceURI($prefix)
+               or error __x"cannot find prefix `{prefix}' for QNAME `{qname}'"
+                     , prefix => $prefix, qname => $qname;
+           pack_type $ns, $qname;
+         };
+
+
+};
+
+
 1;
 
 __END__




More information about the Catalyst-commits mailing list