CAM-SOAPClient

 view release on metacpan or  search on metacpan

lib/CAM/SOAPClient.pm  view on Meta::CPAN

   my $proxy = shift;
   my $user = shift;
   my $pass = shift;

   return if (!$uri);

   my $soap = SOAP::Lite  -> on_fault( sub {} );
   my $self = bless {
      %cfg,
      services => {},
      soap => $soap,
      auth => {},
      global_proxy => undef,
      global_uri => undef,
      proxies => {},
      uris => {},
   }, $pkg;

   if ($uri eq 'wsdl')
   {
      $self->setWSDL($proxy);
   }
   else
   {
      $self->setURI($uri);
      if ($proxy)
      {
         $self->setProxy($proxy);
      }
   }

   if ($user)
   {
      $self->setUserPass($user, $pass);
   }
   return $self;
}

=item $self->setWSDL($url)

Loads a Web Service Description Language file describing the SOAP service.

=cut

sub setWSDL
{
   my $self = shift;
   my $url = shift;
   
   # The SOAP::Schema API changed as of SOAP::Lite v0.65-beta2
   my $schema = SOAP::Schema->can('schema_url') ?
       SOAP::Schema->schema_url($url) :
       SOAP::Schema->schema($url);
   my $services = $schema->parse()->services();
   #use Data::Dumper; print STDERR Dumper($services);

   foreach my $class (values %{$services})
   {
      foreach my $method (keys %{$class})
      {
         my $endpoint = $class->{$method}->{endpoint};
         # 'uri' was used thru SOAP::Lite v0.60, 'namespace' is used in v0.65+
         my $namespace = $class->{$method}->{uri} ? $class->{$method}->{uri}->value() : $class->{$method}->{namespace};
         $self->{proxies}->{$method} = $endpoint ? $endpoint->value() : undef;
         $self->{uris}->{$method} = $namespace;
      }
   }

   return $self;
}

=item $self->setURI($uri)

Specifies the URI for the SOAP server.  This is not needed if you are
using WSDL.

=cut

sub setURI
{
   my $self = shift;
   my $uri = shift;

   $self->{global_uri} = $uri;
   return $self;
}

=item $self->setProxy($proxy)

Specifies the URL for the SOAP server.  This is not needed if you are
using WSDL.

=cut

sub setProxy
{
   my $self = shift;
   my $proxy = shift;

   $self->{global_proxy} = $proxy;
   return $self;
}

=item $self->setUserPass($username, $password)

Specifies the C<$username> and C<$password> to use on the SOAP server.
These values are stored until used via loginParams().  Most
applications won't use this method.

=cut

sub setUserPass
{
   my $self = shift;
   my $username = shift;
   my $password = shift;

   $self->{auth}->{username} = $username;
   $self->{auth}->{password} = $password;
   return $self;
}

=item $self->getLastSOM()



( run in 1.209 second using v1.01-cache-2.11-cpan-df04353d9ac )