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

RE: [soaplite] Re: DBI and SOAP::LITE

Expand Messages
  • Chris Davies
    Can you use DBI in a similar CGI script without SOAP? If not, you ll need to get that to work first. Remember that CGI scripts (generally) run as the web user
    Message 1 of 10 , Jul 4, 2001
    • 0 Attachment
      Can you use DBI in a similar CGI script without SOAP? If not, you'll need to
      get that to work first.

      Remember that CGI scripts (generally) run as the web user rather than
      yourself, so you need to ensure that the web user can access your database.

      Chris

      -----Original Message-----
      From: caboose@... [mailto:caboose@...]
      Sent: Wednesday, July 04, 2001 1:40 PM
      To: soaplite@yahoogroups.com
      Subject: [soaplite] Re: DBI and SOAP::LITE


      Hmm, I just found something. DBI needs a modified LD_LIBRARY_PATH to
      run. I added this to the skript, but it still won't work.

      Are there any other ENV Variables needed? I'm stumbling in the dark.
      because there are no errors visible in the server log file.

      All other CGI / SOAP::LITE scripts work fine, so it has to be
      something DBI specific here.

      Any help?
      Sabine
    • Chris Davies
      Try including this near the top of the program: use CGI::Carp qw(fatalsToBrowser) and then (later): my $dbh =
      Message 2 of 10 , Jul 4, 2001
      • 0 Attachment
        Try including this near the top of the program:
        use CGI::Carp qw(fatalsToBrowser)

        and then (later):
        my $dbh =
        DBI->connect("DBI:mysql:database=delivery;host=brest.c-lab.de","root","") ||
        die "Cannot connect to database: $DBI::errstr";

        Ideally you'll want to catch all errors, so include {RaiseError => 1} in the
        DBI attributes, or else check each return value:
        my $sth = $dbh->prepare("SELECT * from documents WHERE name='$doc'") ||
        die "Cannot prepare SELECT statement: $DBI::errstr";
        $sth->execute() ||
        die "Cannot execute statement: $DBI::errstr";

        As I mentioned in another email, if you're having problems with a CGI script
        containing both DBI and SOAP, try isolating the problem. For example, check
        that DBI works in your CGI script, and then check that SOAP works in your
        CGI script. It's almost certainly an issue with the CGI script running
        without necessary environment variables, or under a username that doesn't
        have access to your database (or its tables).

        Chris


        -----Original Message-----
        From: caboose@... [mailto:caboose@...]
        Sent: Wednesday, July 04, 2001 1:03 PM
        To: soaplite@yahoogroups.com
        Subject: [soaplite] Re: DBI and SOAP::LITE


        Here's the script and the offending subroutine.


        #! /usr/local/perl-5.6.1/bin/perl -w
        use SOAP::Transport::HTTP;
        use DBI();

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

        package Delivery;
        sub retrieveDocument {
        my ($class, $doc, $name, $passwd) =@_;
        my $returnString="result: ";
        my $dbh =
        DBI->connect("DBI:mysql:database=delivery;host=brest.c-lab.de","root","");
        $returnString="Kein connect: $DBI::errstr";
        #my $sth = $dbh->prepare("SELECT * from documents WHERE name='$doc'");
        #$sth->execute();
        #while (my $ref= $sth->fetchrow_hashref()) {
        #$returnString.= "$ref->{'name'} - $ref->{'place'} - $ref->{'start'} -
        $ref->{'owner'} - $ref->{'date'} - $ref->{'status'}";


        #}
        #$sth->finish();
        $dbh->disconnect();
        return $returnString;
        }
      • caboose@c-lab.de
        If I could do that, I wouldn t be asking around. My problem is that the line DBI- connect ( DBI:mysql:database=delivery;host=brest.c-lab.de , root , ) never
        Message 3 of 10 , Jul 4, 2001
        • 0 Attachment
          If I could do that, I wouldn't be asking around.
          My problem is that the line DBI->connect
          ("DBI:mysql:database=delivery;host=brest.c-lab.de","root","")
          never completes execution. Whatever values (true or nonsense) I give
          for the paramaters it does nowt. I can even put in nonsense for the
          driver (mysql) it's still the same.

          It never gets to the ored die part.

          Any further line will never be exectuted. It seems to be stuck
          somewhere in the DBI: part and never get any further.

          Sabine

          --- In soaplite@y..., "Chris Davies" <Chris.Davies@M...> wrote:
          > Try including this near the top of the program:
          > use CGI::Carp qw(fatalsToBrowser)
          >
          > and then (later):
          > my $dbh =
          > DBI->connect("DBI:mysql:database=delivery;host=brest.c-
          lab.de","root","") ||
          > die "Cannot connect to database: $DBI::errstr";
          >
          > Ideally you'll want to catch all errors, so include {RaiseError =>
          1} in the
          > DBI attributes, or else check each return value:
          > my $sth = $dbh->prepare("SELECT * from documents WHERE
          name='$doc'") ||
          > die "Cannot prepare SELECT statement: $DBI::errstr";
          > $sth->execute() ||
          > die "Cannot execute statement: $DBI::errstr";
          >
          > As I mentioned in another email, if you're having problems with a
          CGI script
          > containing both DBI and SOAP, try isolating the problem. For
          example, check
          > that DBI works in your CGI script, and then check that SOAP works
          in your
          > CGI script. It's almost certainly an issue with the CGI script
          running
          > without necessary environment variables, or under a username that
          doesn't
          > have access to your database (or its tables).
          >
          > Chris
          >
          >
          > -----Original Message-----
          > From: caboose@c... [mailto:caboose@c...]
          > Sent: Wednesday, July 04, 2001 1:03 PM
          > To: soaplite@y...
          > Subject: [soaplite] Re: DBI and SOAP::LITE
          >
          >
          > Here's the script and the offending subroutine.
          >
          >
          > #! /usr/local/perl-5.6.1/bin/perl -w
          > use SOAP::Transport::HTTP;
          > use DBI();
          >
          > SOAP::Transport::HTTP::CGI
          > ->dispatch_to('Delivery')
          > ->handle;
          >
          > package Delivery;
          > sub retrieveDocument {
          > my ($class, $doc, $name, $passwd) =@_;
          > my $returnString="result: ";
          > my $dbh =
          > DBI->connect("DBI:mysql:database=delivery;host=brest.c-
          lab.de","root","");
          > $returnString="Kein connect: $DBI::errstr";
          > #my $sth = $dbh->prepare("SELECT * from documents WHERE
          name='$doc'");
          > #$sth->execute();
          > #while (my $ref= $sth->fetchrow_hashref()) {
          > #$returnString.= "$ref->{'name'} - $ref->{'place'} - $ref->
          {'start'} -
          > $ref->{'owner'} - $ref->{'date'} - $ref->{'status'}";
          >
          >
          > #}
          > #$sth->finish();
          > $dbh->disconnect();
          > return $returnString;
          > }
        • Chris Davies
          Sorry, I m puzzled. What can t you do? You should be able to test a CGI script that performs DBI accesses without needing to include SOAP. Something trivial
          Message 4 of 10 , Jul 4, 2001
          • 0 Attachment
            Sorry, I'm puzzled. What can't you do? You should be able to test a CGI
            script that performs DBI accesses without needing to include SOAP. Something
            trivial would do to confirm interoperability. If this simple DBI program
            doesn't work (syntax errors excepted, of course) then it's clearly not a
            SOAP issue and you'll need to investigate the DBI problems elsewhere.

            use strict;
            use CGI::Carp;
            use DBI;

            my $dbh = DBI->connect (...) || die "connect: $DBI::errstr";
            my $sth = $dbh->prepare ("SELECT...") || die "prepare: $DBI::errstr";
            $sth->execute;

            print "Content-type: text/plain\n\n";
            while (my $row = $sth->fetchrow_hashref) {
            print map { "$_ = $row->{$_} } keys %$row, "\n";
            }
            $sth->finish;
            $dbh->disconnect;
            print "All done\n";
            exit 0;
            # E&OE of course

            I'll pick this up again tomorrow.
            Cheers,
            Chris


            -----Original Message-----
            From: caboose@... [mailto:caboose@...]
            Sent: Wednesday, July 04, 2001 5:23 PM
            To: soaplite@yahoogroups.com
            Subject: [soaplite] Re: DBI and SOAP::LITE



            If I could do that, I wouldn't be asking around.
            My problem is that the line DBI->connect
            ("DBI:mysql:database=delivery;host=brest.c-lab.de","root","")
            never completes execution. Whatever values (true or nonsense) I give
            for the paramaters it does nowt. I can even put in nonsense for the
            driver (mysql) it's still the same.

            It never gets to the ored die part.

            Any further line will never be exectuted. It seems to be stuck
            somewhere in the DBI: part and never get any further.

            Sabine

            --- In soaplite@y..., "Chris Davies" <Chris.Davies@M...> wrote:
            > Try including this near the top of the program:
            > use CGI::Carp qw(fatalsToBrowser)
            >
            > and then (later):
            > my $dbh =
            > DBI->connect("DBI:mysql:database=delivery;host=brest.c-
            lab.de","root","") ||
            > die "Cannot connect to database: $DBI::errstr";
            >
            > Ideally you'll want to catch all errors, so include {RaiseError =>
            1} in the
            > DBI attributes, or else check each return value:
            > my $sth = $dbh->prepare("SELECT * from documents WHERE
            name='$doc'") ||
            > die "Cannot prepare SELECT statement: $DBI::errstr";
            > $sth->execute() ||
            > die "Cannot execute statement: $DBI::errstr";
            >
            > As I mentioned in another email, if you're having problems with a
            CGI script
            > containing both DBI and SOAP, try isolating the problem. For
            example, check
            > that DBI works in your CGI script, and then check that SOAP works
            in your
            > CGI script. It's almost certainly an issue with the CGI script
            running
            > without necessary environment variables, or under a username that
            doesn't
            > have access to your database (or its tables).
            >
            > Chris
          • caboose@c-lab.de
            Well, I m a far as that (since about 5 min):even though I have changed the ENV Variable LD_LIBRARY_PATH DBI still cant locate libz.so. I couldn t see this
            Message 5 of 10 , Jul 4, 2001
            • 0 Attachment
              Well, I'm a far as that (since about 5 min):even though I have
              changed the ENV Variable LD_LIBRARY_PATH DBI still cant locate
              libz.so.

              I couldn't see this error because of the Soap Encapsulation.
              When I moved the DB access in front of the SOAP stuff it showed up in
              the server log.

              So I'm bugging out Perl guru with it, tomorrow morning. Thanks for
              trying.

              --- In soaplite@y..., "Chris Davies" <Chris.Davies@M...> wrote:
              > Sorry, I'm puzzled. What can't you do? You should be able to test a
              CGI
              > script that performs DBI accesses without needing to include SOAP.
              Something
              > trivial would do to confirm interoperability. If this simple DBI
              program
              > doesn't work (syntax errors excepted, of course) then it's clearly
              not a
              > SOAP issue and you'll need to investigate the DBI problems
              elsewhere.
              >
              > use strict;
              > use CGI::Carp;
              > use DBI;
              >
              > my $dbh = DBI->connect (...) || die "connect: $DBI::errstr";
              > my $sth = $dbh->prepare ("SELECT...") || die "prepare:
              $DBI::errstr";
              > $sth->execute;
              >
              > print "Content-type: text/plain\n\n";
              > while (my $row = $sth->fetchrow_hashref) {
              > print map { "$_ = $row->{$_} } keys %$row, "\n";
              > }
              > $sth->finish;
              > $dbh->disconnect;
              > print "All done\n";
              > exit 0;
              > # E&OE of course
              >
              > I'll pick this up again tomorrow.
              > Cheers,
              > Chris
              >
              >
              > -----Original Message-----
              > From: caboose@c... [mailto:caboose@c...]
              > Sent: Wednesday, July 04, 2001 5:23 PM
              > To: soaplite@y...
              > Subject: [soaplite] Re: DBI and SOAP::LITE
              >
              >
              >
              > If I could do that, I wouldn't be asking around.
              > My problem is that the line DBI->connect
              > ("DBI:mysql:database=delivery;host=brest.c-lab.de","root","")
              > never completes execution. Whatever values (true or nonsense) I give
              > for the paramaters it does nowt. I can even put in nonsense for the
              > driver (mysql) it's still the same.
              >
              > It never gets to the ored die part.
              >
              > Any further line will never be exectuted. It seems to be stuck
              > somewhere in the DBI: part and never get any further.
              >
              > Sabine
              >
              > --- In soaplite@y..., "Chris Davies" <Chris.Davies@M...> wrote:
              > > Try including this near the top of the program:
              > > use CGI::Carp qw(fatalsToBrowser)
              > >
              > > and then (later):
              > > my $dbh =
              > > DBI->connect("DBI:mysql:database=delivery;host=brest.c-
              > lab.de","root","") ||
              > > die "Cannot connect to database: $DBI::errstr";
              > >
              > > Ideally you'll want to catch all errors, so include {RaiseError =>
              > 1} in the
              > > DBI attributes, or else check each return value:
              > > my $sth = $dbh->prepare("SELECT * from documents WHERE
              > name='$doc'") ||
              > > die "Cannot prepare SELECT statement: $DBI::errstr";
              > > $sth->execute() ||
              > > die "Cannot execute statement: $DBI::errstr";
              > >
              > > As I mentioned in another email, if you're having problems with a
              > CGI script
              > > containing both DBI and SOAP, try isolating the problem. For
              > example, check
              > > that DBI works in your CGI script, and then check that SOAP works
              > in your
              > > CGI script. It's almost certainly an issue with the CGI script
              > running
              > > without necessary environment variables, or under a username that
              > doesn't
              > > have access to your database (or its tables).
              > >
              > > Chris
            • Paul Kulchenko
              Hi, Sabine! I m not sure that s will help, but it s not enough to specify LD_LIBRARY_PATH. YOu need to pass it to your CGI script. Documentation for
              Message 6 of 10 , Jul 4, 2001
              • 0 Attachment
                Hi, Sabine!

                I'm not sure that's will help, but it's not enough to specify
                LD_LIBRARY_PATH. YOu need to pass it to your CGI script.
                Documentation for SOAP::Transport::HTTP has this:

                =item Dynamic libraries are not found

                If you see in webserver's log file something like this:

                Can't load
                '/usr/local/lib/perl5/site_perl/.../XML/Parser/Expat/Expat.so'
                for module XML::Parser::Expat: dynamic linker: /usr/local/bin/perl:
                libexpat.so.0 is NEEDED, but object does not exist at
                /usr/local/lib/perl5/.../DynaLoader.pm line 200.

                and you are using Apache web server, try to put into your httpd.conf

                <IfModule mod_env.c>
                PassEnv LD_LIBRARY_PATH
                </IfModule>

                Hope it helps.

                Best wishes, Paul.

                --- caboose@... wrote:
                > Well, I'm a far as that (since about 5 min):even though I have
                > changed the ENV Variable LD_LIBRARY_PATH DBI still cant locate
                > libz.so.
                >
                > I couldn't see this error because of the Soap Encapsulation.
                > When I moved the DB access in front of the SOAP stuff it showed up
                > in
                > the server log.
                >
                > So I'm bugging out Perl guru with it, tomorrow morning. Thanks for
                > trying.
                >
                > --- In soaplite@y..., "Chris Davies" <Chris.Davies@M...> wrote:
                > > Sorry, I'm puzzled. What can't you do? You should be able to test
                > a
                > CGI
                > > script that performs DBI accesses without needing to include
                > SOAP.
                > Something
                > > trivial would do to confirm interoperability. If this simple DBI
                > program
                > > doesn't work (syntax errors excepted, of course) then it's
                > clearly
                > not a
                > > SOAP issue and you'll need to investigate the DBI problems
                > elsewhere.
                > >
                > > use strict;
                > > use CGI::Carp;
                > > use DBI;
                > >
                > > my $dbh = DBI->connect (...) || die "connect: $DBI::errstr";
                > > my $sth = $dbh->prepare ("SELECT...") || die "prepare:
                > $DBI::errstr";
                > > $sth->execute;
                > >
                > > print "Content-type: text/plain\n\n";
                > > while (my $row = $sth->fetchrow_hashref) {
                > > print map { "$_ = $row->{$_} } keys %$row, "\n";
                > > }
                > > $sth->finish;
                > > $dbh->disconnect;
                > > print "All done\n";
                > > exit 0;
                > > # E&OE of course
                > >
                > > I'll pick this up again tomorrow.
                > > Cheers,
                > > Chris
                > >
                > >
                > > -----Original Message-----
                > > From: caboose@c... [mailto:caboose@c...]
                > > Sent: Wednesday, July 04, 2001 5:23 PM
                > > To: soaplite@y...
                > > Subject: [soaplite] Re: DBI and SOAP::LITE
                > >
                > >
                > >
                > > If I could do that, I wouldn't be asking around.
                > > My problem is that the line DBI->connect
                > > ("DBI:mysql:database=delivery;host=brest.c-lab.de","root","")
                > > never completes execution. Whatever values (true or nonsense) I
                > give
                > > for the paramaters it does nowt. I can even put in nonsense for
                > the
                > > driver (mysql) it's still the same.
                > >
                > > It never gets to the ored die part.
                > >
                > > Any further line will never be exectuted. It seems to be stuck
                > > somewhere in the DBI: part and never get any further.
                > >
                > > Sabine
                > >
                > > --- In soaplite@y..., "Chris Davies" <Chris.Davies@M...> wrote:
                > > > Try including this near the top of the program:
                > > > use CGI::Carp qw(fatalsToBrowser)
                > > >
                > > > and then (later):
                > > > my $dbh =
                > > > DBI->connect("DBI:mysql:database=delivery;host=brest.c-
                > > lab.de","root","") ||
                > > > die "Cannot connect to database: $DBI::errstr";
                > > >
                > > > Ideally you'll want to catch all errors, so include {RaiseError
                > =>
                > > 1} in the
                > > > DBI attributes, or else check each return value:
                > > > my $sth = $dbh->prepare("SELECT * from documents WHERE
                > > name='$doc'") ||
                > > > die "Cannot prepare SELECT statement: $DBI::errstr";
                > > > $sth->execute() ||
                > > > die "Cannot execute statement: $DBI::errstr";
                > > >
                > > > As I mentioned in another email, if you're having problems with
                > a
                > > CGI script
                > > > containing both DBI and SOAP, try isolating the problem. For
                > > example, check
                > > > that DBI works in your CGI script, and then check that SOAP
                > works
                > > in your
                > > > CGI script. It's almost certainly an issue with the CGI script
                > > running
                > > > without necessary environment variables, or under a username
                > that
                > > doesn't
                > > > have access to your database (or its tables).
                > > >
                > > > Chris
                >
                >
                > To unsubscribe from this group, send an email to:
                > soaplite-unsubscribe@yahoogroups.com
                >
                >
                >
                > Your use of Yahoo! Groups is subject to
                > http://docs.yahoo.com/info/terms/
                >
                >


                __________________________________________________
                Do You Yahoo!?
                Get personalized email addresses from Yahoo! Mail
                http://personal.mail.yahoo.com/
              Your message has been successfully submitted and would be delivered to recipients shortly.