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

Do SOAP::Lit and CGI support database-MySQL?

Expand Messages
  • shihewang
    Hello, Anybody knows if SOAP::Lite and CGI support database, say MySQL? Please let me know. My test results are negative. I am not sure if my codes are
    Message 1 of 5 , Sep 9 7:45 PM
    • 0 Attachment
      Hello,

      Anybody knows if SOAP::Lite and CGI support database, say MySQL?
      Please let me know.

      My test results are negative. I am not sure if my codes are correct.
      1. SOAP::Lite
      **************************************************************
      **** Server
      **************************************************************
      #!/usr/bin/perl -w
      # file: mysoap.cgi

      use DBI;
      use SOAP::Transport::HTTP;

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

      package Mysoap;

      sub search_db
      {
      use DBI;
      my $db_name = "";
      my $passwd = "";
      my $login = "";
      $dbh =DBI->connect("DBI:mysql:$db_name", $login, $passwd)

      $sth=$dbh->prepare(qq{select id from test where id =1});
      $sth -> execute;
      my $retval = $sth->fecthrow;
      return $retval;
      }

      1;
      #end mysoap.cgi

      **************************************************************
      **** Client
      **************************************************************
      #!/usr/bin/perl -w
      # file: test.pl

      use SOAP::Lite;
      my $soap =SOAP::Lite
      ->uri("urn:Mysoap")
      ->proxy("http://www.dept.university.edu/~mylogin/cgi-
      bin/mysoap.cgi")
      ->hi();
      print $soap->result;
      print "see result from database?\n";

      Error msg is:
      Use of uninitialized value in concatenation (.) or string at test1.pl
      line 9.


      2 CGI
      **************************************************************
      **** cgi
      **************************************************************
      #!/usr/bin/perl -w
      # file: test1.pl

      use CGI;
      use DBI;

      my $test = CGI -> new();

      print $test -> header();
      print $test -> start_html
      ( -title => 'Test Database',
      -target => '_new',
      -BGCOLOR => 'dddddd');

      print "Wait, I am fecthing data from db ...<br>";

      my $db_name = <STDIN>;
      my $passwd = <STDIN>;
      my $login = <STDIN>;

      $dbh =DBI->connect("DBI:mysql:$db_name", $login, $passwd);
      $sth=$dbh->prepare(qq{select id from test where id=1});
      $sth -> execute;
      my $result = $sth->fetchrow;
      print $result;
      print $test -> end_html();

      #end test1.pl

      When ran on command line, there's "1", but when use browser point to
      test1.pl, there's no "1".
    • Duncan Cameron
      ... Are you getting any server errors? I suggest putting the Mysoap package either *before* the call to SOAP:Transport (and then switching back to the main
      Message 2 of 5 , Sep 9 9:54 PM
      • 0 Attachment
        On 2002-09-10 shihewang wrote:
        >Hello,
        >
        >Anybody knows if SOAP::Lite and CGI support database, say MySQL?
        >Please let me know.
        >
        >My test results are negative. I am not sure if my codes are correct.
        >1. SOAP::Lite
        >**************************************************************
        >**** Server
        >**************************************************************
        >#!/usr/bin/perl -w
        ># file: mysoap.cgi
        >
        > use DBI;
        > use SOAP::Transport::HTTP;
        >
        > SOAP::Transport::HTTP::CGI
        > -> dispatch_to('Mysoap')
        > -> handle;
        >
        > package Mysoap;
        >
        > sub search_db
        > {
        > use DBI;
        > my $db_name = "";
        > my $passwd = "";
        > my $login = "";
        > $dbh =DBI->connect("DBI:mysql:$db_name", $login, $passwd)
        >
        > $sth=$dbh->prepare(qq{select id from test where id =1});
        > $sth -> execute;
        > my $retval = $sth->fecthrow;
        > return $retval;
        > }
        >
        >1;
        >#end mysoap.cgi

        Are you getting any server errors?
        I suggest putting the Mysoap package either *before* the
        call to SOAP:Transport (and then switching back to the main package)
        or into a separate file.

        >**************************************************************
        >**** Client
        >**************************************************************
        >#!/usr/bin/perl -w
        ># file: test.pl
        >
        >use SOAP::Lite;
        >my $soap =SOAP::Lite
        > ->uri("urn:Mysoap")
        > ->proxy("http://www.dept.university.edu/~mylogin/cgi-
        >bin/mysoap.cgi")
        > ->hi();

        There is no hi() method in Mysoap package.

        Regards,
        Duncan Cameron
      • Shihe Wang
        Duncan, Thanks for yor response. ... there s no server msg detected. Do you mean dynamic deployment? Does it make any difference? ...
        Message 3 of 5 , Sep 10 4:59 AM
        • 0 Attachment
          Duncan,
          Thanks for yor response.
          --- Duncan Cameron <dcameron@...> wrote:
          > On 2002-09-10 shihewang wrote:
          > >Hello,
          > >
          > >Anybody knows if SOAP::Lite and CGI support
          > database, say MySQL?
          > >Please let me know.
          > >
          > >My test results are negative. I am not sure if my
          > codes are correct.
          > >1. SOAP::Lite
          >
          >**************************************************************
          > >**** Server
          >
          >**************************************************************
          > >#!/usr/bin/perl -w
          > ># file: mysoap.cgi
          > >
          > > use DBI;
          > > use SOAP::Transport::HTTP;
          > >
          > > SOAP::Transport::HTTP::CGI
          > > -> dispatch_to('Mysoap')
          > > -> handle;
          > >
          > > package Mysoap;
          > >
          > > sub search_db
          > > {
          > > use DBI;
          > > my $db_name = "";
          > > my $passwd = "";
          > > my $login = "";
          > > $dbh =DBI->connect("DBI:mysql:$db_name",
          > $login, $passwd)
          > >
          > > $sth=$dbh->prepare(qq{select id from test
          > where id =1});
          > > $sth -> execute;
          > > my $retval = $sth->fecthrow;
          > > return $retval;
          > > }
          > >
          > >1;
          > >#end mysoap.cgi
          >
          > Are you getting any server errors?
          > I suggest putting the Mysoap package either *before*
          > the
          > call to SOAP:Transport (and then switching back to
          > the main package)
          > or into a separate file.
          >
          there's no server msg detected.
          Do you mean dynamic deployment? Does it make any
          difference?

          >
          >**************************************************************
          > >**** Client
          >
          >**************************************************************
          > >#!/usr/bin/perl -w
          > ># file: test.pl
          > >
          > >use SOAP::Lite;
          > >my $soap =SOAP::Lite
          > > ->uri("urn:Mysoap")
          > >
          >
          ->proxy("http://www.dept.university.edu/~mylogin/cgi-
          > >bin/mysoap.cgi")
          > > ->hi();
          >
          > There is no hi() method in Mysoap package.
          This is a mistake. It should be search_db() rather
          than hi(). Sorry.
          >
          > Regards,
          > Duncan Cameron
          >

          Did you test DBI within CGI or SOAP::Lite? Could you
          show me an example?
          Thanks.
          Shawn Wang

          __________________________________________________
          Yahoo! - We Remember
          9-11: A tribute to the more than 3,000 lives lost
          http://dir.remember.yahoo.com/tribute
        • Dougal Campbell
          ... ^^^^^^^^ Is this typo (should be fetchrow ) in the code you re trying to run, or was that just a transcription error when you composed the email? --
          Message 4 of 5 , Sep 10 6:29 AM
          • 0 Attachment
            On Tue, 10 Sep 2002, shihewang wrote:

            > [....]
            > $sth=$dbh->prepare(qq{select id from test where id =1});
            > $sth -> execute;
            > my $retval = $sth->fecthrow;
            ^^^^^^^^

            Is this typo (should be 'fetchrow') in the code you're trying to run, or
            was that just a transcription error when you composed the email?

            --
            Ernest MacDougal Campbell III, MCP+I, MCSE <dougal@...>
            http://dougal.gunters.org/ http://spam.gunters.org/
            Web Design & Development: http://www.mentalcollective.com/
            This message is guaranteed to be 100% eror frea!
          • shihewang
            ... run, or ... You are right. It is a mistake when compose the email. The code is my $result = $sth- fetchrow; Sorry. Shawn Wang
            Message 5 of 5 , Sep 10 7:13 AM
            • 0 Attachment
              --- In soaplite@y..., Dougal Campbell <dougal@g...> wrote:
              > On Tue, 10 Sep 2002, shihewang wrote:
              >
              > > [....]
              > > $sth=$dbh->prepare(qq{select id from test where id =1});
              > > $sth -> execute;
              > > my $retval = $sth->fecthrow;
              > ^^^^^^^^
              >
              > Is this typo (should be 'fetchrow') in the code you're trying to
              run, or
              > was that just a transcription error when you composed the email?
              >
              > --
              > Ernest MacDougal Campbell III, MCP+I, MCSE <dougal@g...>
              > http://dougal.gunters.org/ http://spam.gunters.org/
              > Web Design & Development: http://www.mentalcollective.com/
              > This message is guaranteed to be 100% eror frea!

              You are right. It is a mistake when compose the email. The code is
              my $result = $sth->fetchrow;
              Sorry.
              Shawn Wang
            Your message has been successfully submitted and would be delivered to recipients shortly.