Loading ...
Sorry, an error occurred while loading the content.

use_prefix warnings update

Expand Messages
  • Byrne Reese
    Dear SOAP::Lite Users, I am uploading into CPAN as we speak SOAP::Lite 0.66.1 - this is a MINOR release that simply suppresses the warning message about the
    Message 1 of 1 , Jan 4, 2006
    • 0 Attachment
      Dear SOAP::Lite Users,

      I am uploading into CPAN as we speak SOAP::Lite 0.66.1 - this is a MINOR
      release that simply suppresses the warning message about the use of
      use_prefix. It does not fix any other underlying problems. I wanted to
      get this out there as a stop gap so that people's error logs weren't
      getting spammed with these warning messages.

      Meanwhile, I working on unraveling a bit of the SOAP::Lite code base to
      see if I can't fix the problem more elegantly. I am using the Delayed
      Stock Quote service as a core use case, and so far I have been unable to
      send a message to it without hacking the source code directly to swap
      out the use of "ns()" for "default_ns()". Long story short, I have some
      work to do. My sincerest apologies for any trouble this has caused. I am
      working on a fix. But if you have ever looked at the SOAP::Lite source
      code, you may have some empathy for me. Paul (the original author) is a
      genius (sincerely), but reading the notes of a genius can be
      excruciating work sometimes. :)

      Anyway - here is what I am proposing I do:

      I am going to rewrite the source code that SOAP::Lite generates from a
      WSDL file, then I am going to modify SOAP::Lite to generate that
      sourcecode as opposed to what it is generated currently.

      Take a look at this code:
      my $client = SOAP::Lite->service(<URL TO WSDL>);

      Now, let me ask you: what do you think is the object type of the $client
      variable? The intuitive response I believe is the same thing that would
      be returned if I called:
      my $client = SOAP::Lite->proxy(<URL TO endpoint>)->ns(<NAMESPACE>);

      Or in other words, an instance of a SOAP::Lite client. It is in fact an
      instance of net_xmethods_services_stockquote_StockQuoteService. Which is
      fine by me assuming I can still access the accessors or a SOAP::Lite
      client to toggle the use of a default namespace or not.

      Anyway, for the Perl hackers out there who are interested - here is a
      snapshot of the code SOAP::Lite generates based upon a WSDL. You may
      notice that it is not that object oriented. I need to fix that. But then
      again, there are sooooo many things about SOAP::Lite I need to fix.

      # Generated by SOAP::Lite (v0.66) for Perl -- soaplite.com
      # Copyright (C) 2000-2006 Paul Kulchenko, Byrne Reese
      # -- generated at [Wed Jan 4 14:06:54 2006]
      # -- generated from http://www.xmethods.net/sd/StockQuoteService.wsdl
      package net_xmethods_services_stockquote_StockQuoteService;
      my %methods = (
      getQuote => {
      endpoint => 'http://services.xmethods.net/soap',
      soapaction => 'urn:xmethods-delayed-quotes#getQuote',
      namespace => 'urn:xmethods-delayed-quotes',
      parameters => [
      SOAP::Data->new(name => 'symbol', type => 'xsd:string', attr => {}),
      ], # end parameters
      }, # end getQuote
      ); # end my %methods

      use SOAP::Lite;
      use Exporter;
      use Carp ();

      use vars qw(@ISA $AUTOLOAD @EXPORT_OK %EXPORT_TAGS);
      @ISA = qw(Exporter SOAP::Lite);
      @EXPORT_OK = (keys %methods);
      %EXPORT_TAGS = ('all' => [@EXPORT_OK]);

      sub _call {
      my ($self, $method) = (shift, shift);
      my $name = UNIVERSAL::isa($method => 'SOAP::Data') ? $method->name :
      $method;
      my %method = %{$methods{$name}};
      $self->proxy($method{endpoint} || Carp::croak "No server address
      (proxy) specified")
      unless $self->proxy;
      my @templates = @{$method{parameters}};
      my @parameters = ();
      foreach my $param (@_) {
      if (@templates) {
      my $template = shift @templates;
      my ($prefix,$typename) = SOAP::Utils::splitqname($template->type);
      my $method = 'as_'.$typename;
      # TODO - if can('as_'.$typename) {...}
      my $result = $self->serializer->$method($param, $template->name,
      $template->type, $template->attr);
      push(@parameters, $template->value($result->[2]));
      } else {
      push(@parameters, $param);
      }
      }
      $self->endpoint($method{endpoint})
      ->ns($method{namespace})
      ->on_action(sub{qq!"$method{soapaction}"!});

      $self->serializer->register_ns("http://www.themindelectric.com/","electric");

      $self->serializer->register_ns("http://schemas.xmlsoap.org/wsdl/soap/","soap");
      $self->serializer->register_ns("http://schemas.xmlsoap.org/wsdl/","wsdl");

      $self->serializer->register_ns("http://schemas.xmlsoap.org/soap/encoding/","soapenc");

      $self->serializer->register_ns("http://www.themindelectric.com/wsdl/net.xmethods.services.stockquote.St
      ockQuote/","tns");
      $self->serializer->register_ns("http://www.w3.org/2001/XMLSchema","xsd");
      my $som = $self->SUPER::call($method => @parameters);
      if ($self->want_som) {
      return $som;
      }
      UNIVERSAL::isa($som => 'SOAP::SOM') ? wantarray ? $som->paramsall :
      $som->result : $som;
      }

      sub BEGIN {
      no strict 'refs';
      for my $method (qw(want_som)) {
      my $field = '_' . $method;
      *$method = sub {
      my $self = shift->new;
      @_ ? ($self->{$field} = shift, return $self) : return $self->{$field};
      }
      }
      }
      no strict 'refs';
      for my $method (@EXPORT_OK) {
      my %method = %{$methods{$method}};
      *$method = sub {
      my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
      ? ref $_[0] ? shift # OBJECT
      # CLASS, either get self or create new and assign to self
      : (shift->self || __PACKAGE__->self(__PACKAGE__->new))
      # function call, either get self or create new and assign to self
      : (__PACKAGE__->self || __PACKAGE__->self(__PACKAGE__->new));
      $self->_call($method, @_);
      }
      }

      sub AUTOLOAD {
      my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::') + 2);
      return if $method eq 'DESTROY' || $method eq 'want_som';
      die "Unrecognized method '$method'. List of available method(s):
      @EXPORT_OK\n";
      }

      1;
    Your message has been successfully submitted and would be delivered to recipients shortly.