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

Yet Another "Denied access to method" error.

Expand Messages
  • Hugo Mills
    I m trying to use Apache mod-perl to host a service, and I m getting the traditional Denied access error. I have two packages, Timestamp::Server to act as
    Message 1 of 3 , Jul 29, 2003
    • 0 Attachment
      I'm trying to use Apache mod-perl to host a service, and I'm
      getting the traditional "Denied access" error. I have two packages,
      Timestamp::Server to act as the server itself, and Timestamp::Service
      to perform the actual functions.

      I've tried more or less every combination of code that I can find
      to create / dispatch the service in Server.pm. I've tried searching
      the mailing list archives, but none of the "Denied access" threads I
      can find seem to give a solution which shows any change for me. Can
      anyone help me to sort this out?

      Thanks,
      An extremely frustrated Hugo.

      Code as follows:

      Timestamp/Server.pm:

      -----------
      #!/usr/bin/perl -w

      use lib qw(/usr/share/perl5 /usr/local/lib/site_perl);

      package Timestamp::Server;
      use strict;
      use SOAP::Lite +trace => 'all';
      use SOAP::Transport::HTTP;
      use Timestamp::Service;

      my $srv = new SOAP::Transport::HTTP::Apache
      ->dispatch_to({"urn:/Timestamp/Service" => "Timestamp::Service"});

      sub handler() { $srv->handler(@_); }

      1;
      -----------

      Timestamp/Service.pm:

      -----------
      #!/usr/bin/perl -w

      use lib qw(/usr/share/perl5 /usr/local/lib/site_perl);

      package Timestamp::Service;
      use Sys::Syslog;
      use Digest::SHA1 qw(sha1_hex);
      use POSIX;
      use strict;

      sub new {
      my $proto = shift;
      my $class = ref($proto) || $proto;
      my $self = {};
      $self->{key} = `cat /usr/local/lib/site_perl/Timestamp/key.uu`;
      bless ($self, $class);
      return $self;
      }

      # The function itself
      sub stampHash
      {
      my ($self, $data) = @_;

      # Do some stuff

      return ($timestring, $hash);
      }

      1;
      -----------

      Finally, the client:

      -----------
      #!/usr/bin/perl -w

      use strict 'vars';
      use SOAP::Lite +trace => 'all';
      use Digest::SHA1;

      my $srv = SOAP::Lite->uri("urn:/Timestamp/Service")
      -> proxy("http://mina.ecs.soton.ac.uk/timestamp/");

      $finalreadout = "Some string";

      my @result = $srv->stampHash($finalreadout);

      print "Timestamp: ", $result[0], "\n";
      print "Hash: ", $result[1], "\n";
      -----------

      --
      --- Hugo Mills - <hugo@...> - ECS at Southampton University ---
      --- Comb-e-chem project: http://www.combechem.org/ ---
      Quantum Mechanics: The dreams stuff is made of
    • Hugo Mills
      [Second attempt -- my first doesn t seem to have made it to the list] I m trying to use Apache mod-perl to host a service, and I m getting the traditional
      Message 2 of 3 , Jul 30, 2003
      • 0 Attachment
        [Second attempt -- my first doesn't seem to have made it to the list]

        I'm trying to use Apache mod-perl to host a service, and I'm
        getting the traditional "Denied access" error. I have two packages,
        Timestamp::Server to act as the server itself, and Timestamp::Service
        to perform the actual functions. (Code below)

        I've tried more or less every combination of code that I can find
        to create / dispatch the service in Server.pm. I've tried searching
        the mailing list archives, but none of the "Denied access" threads I
        can find seem to give a solution which shows any change for me. Can
        anyone help me to sort this out?

        Thanks,
        An extremely frustrated Hugo.

        Code as follows:

        Timestamp/Server.pm:

        -----------
        #!/usr/bin/perl -w

        use lib qw(/usr/share/perl5 /usr/local/lib/site_perl);

        package Timestamp::Server;
        use strict;
        use SOAP::Lite +trace => 'all';
        use SOAP::Transport::HTTP;
        use Timestamp::Service;

        my $srv = new SOAP::Transport::HTTP::Apache
        ->dispatch_to({"http://mina.ecs.soton.ac.uk/Timestamp/Service/" => "Timestamp::Service"});

        sub handler() { $srv->handler(@_); }

        1;
        -----------

        Timestamp/Service.pm:

        -----------
        #!/usr/bin/perl -w

        use lib qw(/usr/share/perl5 /usr/local/lib/site_perl);

        package Timestamp::Service;
        use Sys::Syslog;
        use Digest::SHA1 qw(sha1_hex);
        use POSIX;
        use strict;

        sub new {
        my $proto = shift;
        my $class = ref($proto) || $proto;
        my $self = {};
        $self->{key} = `cat /usr/local/lib/site_perl/Timestamp/key.uu`;
        bless ($self, $class);
        return $self;
        }

        # The function itself
        sub stampHash
        {
        my ($self, $data) = @_;

        $timestring = strftime("%F, %T, %z", gmtime());
        $hash = sha1_hex($timestring . " " . $data . " " . $self->{key});

        return ($timestring, $hash);
        }

        1;
        -----------

        Finally, the client:

        -----------
        #!/usr/bin/perl -w

        use strict 'vars';
        use SOAP::Lite +trace => 'all';
        use Digest::SHA1;

        my $srv = SOAP::Lite->uri("http://mina.ecs.soton.ac.uk/Timestamp/Service/")
        -> proxy("http://mina.ecs.soton.ac.uk/timestamp/");

        $finalreadout = "Some string";

        my @result = $srv->stampHash($finalreadout);

        print "Timestamp: ", $result[0], "\n";
        print "Hash: ", $result[1], "\n";
        -----------

        --
        --- Hugo Mills - <hugo@...> - ECS at Southampton University ---
        --- Comb-e-chem project: http://www.combechem.org/ ---
        Quantum Mechanics: The dreams stuff is made of
      • Jeff Schmidt
        I m having a devil of a time trying to get a very simple gSOAP client to talk to a very simple SOAP::Lite server. The server works fine when I use a SOAP::Lite
        Message 3 of 3 , Jul 30, 2003
        • 0 Attachment
          I'm having a devil of a time trying to get a very simple gSOAP client
          to talk to a very simple SOAP::Lite server. The server works fine when
          I use a SOAP::Lite client, but I get the following access denied error
          from the gSOAP client (Mac OS X):

          SOAP FAULT: SOAP-ENV:Client
          "Denied access to method (getStateName) in class (main) at
          /Library/Perl/SOAP/Lite.pm line 2128."

          Relevant logs and code snippets below. Can anyone help me out here?


          *** SENT.log:

          POST /cgi-bin/soap.cgi HTTP/1.1
          Host: localhost
          User-Agent: gSOAP/2.3
          Content-Type: text/xml; charset=utf-8
          Content-Length: 491
          Connection: close
          SOAPAction: "#getStateName"

          <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
          xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmln
          s:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
          http://www.w3.org/2001/XMLSchema"
          xmlns:ns="http://localhost/Statename/"><SOAP-ENV:Body
          SOAP-ENV:encodingStyle="http://s
          chemas.xmlsoap.org/soap/encoding/"
          id="_0"><getStateName><stateNum>23</stateNum></getStateName></SOAP-
          ENV:Body></SOAP-EN
          V:Envelope>



          *** RECV.log:

          HTTP/1.1 500 Internal Server Error
          Date: Wed, 30 Jul 2003 14:32:48 GMT
          Server: Apache/1.3.27 (Darwin) PHP/4.3.0
          SOAPServer: SOAP::Lite/Perl/0.55
          Content-Length: 630
          Connection: close
          Content-Type: text/xml; charset=utf-8

          <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
          xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP
          -ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
          xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/
          " xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
          xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><SOA
          P-ENV:Fault><faultcode
          xsi:type="xsd:string">SOAP-ENV:Client</faultcode><faultstring
          xsi:type="xsd:string">Denied access
          to method (getStateName) in class (main) at /Library/Perl/SOAP/Lite.pm
          line 2128.
          </faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>



          *** Client (gSOAP) code:

          SOAP_NMAC struct Namespace namespaces[] =
          {
          {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/",
          "http://www.w3.org/*/soap-envelope"},
          {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/",
          "http://www.w3.org/*/soap-encoding"},
          {"xsi", "http://www.w3.org/2001/XMLSchema-instance",
          "http://www.w3.org/*/XMLSchema-instance"},
          {"xsd", "http://www.w3.org/2001/XMLSchema",
          "http://www.w3.org/*/XMLSchema"},
          {"ns", "http://localhost/Statename/"},
          {NULL, NULL}
          };


          int call_getStateName(char* url, char* urn, int stateNum, char**
          stateName)
          {
          int retval = 0;
          struct soap soap;
          soap_init(&soap);
          if (retval = soap_call_getStateName(&soap, url, urn, stateNum,
          stateName))
          soap_print_fault(&soap, stderr);

          return retval;
          }


          *** Server (SOAP::Lite) code:

          #!/usr/bin/perl -w

          # -- SOAP::Lite -- soaplite.com -- Copyright (C) 2001 Paul Kulchenko --

          use SOAP::Transport::HTTP;

          SOAP::Transport::HTTP::CGI
          -> dispatch_to('Statename')
          -> handle
          ;


          package Statename;

          sub new {
          bless {}, shift;
          }

          sub test {
          my $self = shift;
          return "Hiya";
          }

          sub getStateName {
          my @states = (undef,
          qw/Alabama Alaska Arizona Arkansas California
          Colorado Connecticut
          Delaware Florida Georgia Hawaii Idaho Illinois
          Indiana Iowa Kansas
          Kentucky Louisiana Maine Maryland Massachusetts
          Michigan Minnesota
          Mississippi Missouri Montana Nebraska Nevada/, 'New
          Hampshire',
          'New Jersey', 'New Mexico', 'New York', 'North
          Carolina',
          'North Dakota', qw/Ohio Oklahoma Oregon
          Pennsylvania/, 'Rhode Island',
          'South Carolina', 'South Dakota', qw/Tennessee Texas
          Utah Vermont
          Virginia Washington/, 'West Virginia', 'Wisconsin',
          'Wyoming'
          );
          my ($self, $idx) = @_;
          return $states[$idx];
          }

          1;


          Jeffrey Schmidt, senior software architect, MultiAd
          jschmidt@..., AIM:jfsaim
        Your message has been successfully submitted and would be delivered to recipients shortly.