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

500 Can't connect to localhost:80 (Permission denied)

Expand Messages
  • fifth_note@yahoo.com
    Hi, I m getting a permission error when I run a cgi script that calls a simple web service. The same web service executes successfully when called from the
    Message 1 of 1 , Jan 7, 2008
    • 0 Attachment
      Hi,

      I'm getting a permission error when I run a cgi script
      that calls a simple web service. The same web service
      executes successfully when called from the Linux
      command line using a different user ID than the web
      service owner. The way I see it, when the scipt calls
      itself (in the action part), that's when the
      permission error happens:
      [Mon Jan 07 22:10:27 2008] [error] [client 127.0.0.1]
      500 Can't connect to localhost:80 (Permission denied)
      at client01.cgi line 194, referer:
      http://localhost/~userx/webclient/client01.cgi

      The directory where the script is has the following
      permission 755 (I changed it from 711, which did not
      work, either). Also the cgi script has the following
      permission:
      -rwxr-xr-x userx userx
      user_u:object_r:httpd_sys_content_t client01.cgi

      Does anybody have any idea why this is happening? Is
      this a web service or http issue? I might be barking
      up the wrong tree.

      Listed below are the codes of scripts I am using.

      Thanks a lot.


      ############# SERVER ####################
      # ============ BEGIN SERVER CODE
      =======================
      #!/usr/bin/perl -w

      use pm01;
      use SOAP::Transport::HTTP;

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

      # ============ END SERVER CODE =======================

      # ============ BEGIN PM01 CODE =======================
      #!/usr/bin/perl -w

      package pm01;

      use DBI;
      use strict;

      use vars qw(@ISA);
      @ISA = qw(SOAP::Server::Parameters);

      #
      -------------------------------------------------------------------
      sub say_hello_plain {
      return "say_hello_plain.Hello";
      }
      #
      -------------------------------------------------------------------
      sub say_hello_soapdata {
      return SOAP::Data->name("echoString" =>
      "say_hello_soapdata.Hello.");
      }
      #
      -------------------------------------------------------------------
      sub add_entry {

      my ($self, $first, $last, $phone, $email) = @_;

      my $dbtype = "mysql";
      my $dbname = "test_db3";
      my $table = "contacts";

      my $DSN = "DBI:$dbtype:$dbname";
      my $db_handle = DBI->connect( $DSN, "", "", {
      RaiseError => 1 } );

      my $ret_val = "$first $last $email";
      my $sqlstatement = "INSERT INTO $table ".
      " (first, last, phone, email )".
      " VALUES ( \'$first\', \'$last\',
      \'$phone\', \'$email\' )";
      $ret_val = $sqlstatement ;

      if ($db_handle->do( $sqlstatement ) ) {
      $ret_val = "added record
      $first:$last:$phone:$email.";
      }
      else {
      $ret_val = "error adding
      $first:$last:$phone:$email";
      }

      return SOAP::Data->name("transactionStatus" =>
      "$ret_val"),
      SOAP::Header->name("transactionHeader" =>
      "Status"),
      SOAP::Header->name("transactionDate" =>
      time() );
      }

      #
      -------------------------------------------------------------------
      1;

      # ============ END PM01 CODE =========================


      ################### CLIENT ##################

      # ============ BEGIN client CGI CODE snippet
      ====================
      sub add_new_entry {

      open_html_page("dummy");

      # ---- debug ------
      print "<pre>";
      # ---- debug ------
      print_debug("in method add_new_entry....");

      my $HOST =
      "http://localhost/~devin/websvc/service01.cgi";
      my $NS = "urn:pm01";

      print_debug("host: $HOST");

      my $first = param('firstname');
      my $last = param('lastname');
      my $phone = param('phone');
      my $email = param('email');

      print_debug("Firstname: $first");
      print_debug("Lastname: $last");
      print_debug("Phone: $phone");
      print_debug("Email: $email");

      my $soap = SOAP::Lite
      ->readable(1)
      ->uri($NS)
      ->proxy($HOST);

      print_debug("Calling method to update table...");

      my $soap_message = $soap->add_entry("$first",
      "$last", "$phone", "$email");

      print_debug("The response from the server was:");
      print_debug($soap_message->result);

      # ---- debug ------
      print "</pre>";
      # ---- debug ------
      close_html_page();

      }
      #
      -----------------------------------------------------
      sub test_01 {

      my $HOST =
      "http://localhost/~devin/websvc/service01.cgi";
      my $NS = "urn:pm01";

      open_html_page("dummy");

      print_debug("Calling hello method ...");

      # ---- debug ------
      print "<pre>";
      # ---- debug ------

      my $soap = SOAP::Lite
      ->readable(1)
      ->uri($NS)
      ->proxy($HOST);

      my $soap_message = $soap->say_hello_plain();

      print "Server response:\n"
      .$soap_message->result."\n\n";

      #
      -----------------------------------------------------

      print "Calling a method with one param...\n";

      my $soap_message = $soap->echo_the_value(
      SOAP::Data->name("whatToEcho" => "$first"));

      print "Server response:\n"
      .$soap_message->result."\n\n";
      #
      ---------------------------------------------------

      print "Calling a method with multiple params\n";
      my $soap_message =
      $soap->multi_value("$first","$last","$email");

      print "Server response:\n"
      .$soap_message->result."\n\n";

      #
      ---------------------------------------------------

      # ---- debug ------
      print "</pre>";
      # ---- debug ------

      close_html_page();
      }
      # ---------------------------------------------------
      sub print_debug {
      print ("@_", "<br>\n");
      }


      # ============ END client CGI CODE snippet ==========





      ____________________________________________________________________________________
      Looking for last minute shopping deals?
      Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
    Your message has been successfully submitted and would be delivered to recipients shortly.