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

1837Re: [soaplite] Does SOAP::Lite support DBI::mysql?

Expand Messages
  • Michael Goepper
    Sep 15 2:27 PM
    • 0 Attachment
      Hi,

      your code is working very well on my machine.

      It seem's, there's a runtime error somewhere (wrong DB login or something
      like this). If your mysoap.cgi dies (in case of a runtime error) -
      SOAP::Lite will create a SOAP-Fault. So you should react on faults in your
      test1.pl like this:

      --test1.pl---->8--------------schnipp----
      #!/usr/bin/perl -w

      use SOAP::Lite;
      my $soap=SOAP::Lite
      ->uri('urn:Mysoap')
      ->proxy( 'http://services.soap-portal.de/mysoap.cgi')
      -> on_fault(sub { my($soap, $res) = @_;
      die ref $res ? $res->faultstring : $soap->transport->status, "\n";
      })
      ->search_db();
      my $result=$soap->result;
      print "result: $result\n";
      --test1.pl---->8--------------schnapp----

      And then you'll see, what went wrong.

      Have fun,
      Michael

      ----------------------
      www.SOAP-PORTAL.DE
      ----------------------

      > Hello,
      > This is second time post the question- Does SOAP::Lie support
      > DBI::mysql? I really care it. If anybody has the answer, please let me
      > know.
      > I created a server-client, mysoap.cgi-test1.pl. They do not work. While
      > the other pair, hibye.cgi-hello.pl, work in the same dir on the same
      > machine. And I copied the sub, search_db, from mysoap.cgi
      > package, and put into test2.pl. test2.pl also works. See the codes and
      > running results(Sorry, codes post a moment ago not readable, now
      > re-post the code):
      >
      > 1. server: mysoap.cgi, client: test1.pl
      > mysoap.cgi
      > *****************************************
      > #!/usr/bin/perl -w
      >
      > # use DBI;#tried either with or without this line
      > use SOAP::Transport::HTTP;
      >
      > SOAP::Transport::HTTP::CGI
      > -> dispatch_to('Mysoap')
      > -> handle;
      >
      > package Mysoap;
      >
      > sub search_db{
      > use DBI;
      > my $db_name = "mydb";
      > my $passwd = "mypasswd";
      > my $login = "mylogin";
      > my $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->fetchrow;
      > return $retval;
      > }
      > 1;
      > *****************************************
      >
      > test1.pl
      > *****************************************
      > #!/usr/bin/perl -w
      >
      > use SOAP::Lite;
      > my $soap=SOAP::Lite
      > ->uri('urn:Mysoap')
      > ->proxy( 'http://www.dept.univ.edu/~mylogin/cgi-bin/mysoap.cgi')
      > ->search_db();
      > my $result=$soap->result;
      > print "result: $result\n";
      > *****************************************
      >
      > Running result:
      > *****************************************
      > %perl test1.pl
      > Use of uninitialized value in concatenation (.) or string at test1.pl
      > line 9.
      > result:
      > %
      > *****************************************
      >
      [...]
      >
      > 3. copy the sub search_db from server mysoap.cgi, put into test2.pl
      > test2.pl
      > *****************************************
      > #!/usr/bin/perl -w
      >
      > sub search_db{
      > use DBI;
      > my $db_name = "mydb";
      > my $passwd = "mypasswd";
      > my $login = "mylogin";
      > my $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->fetchrow;
      > return $retval;
      > }
      >
      > $result = search_db();
      > print "result: $result\n";
      > *****************************************
      >
      > Running result:
      > *****************************************
      > %perl test2.pl
      > result: 1
      > %
      > *****************************************
      >
      >
      >
      >
      > 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/
    • Show all 7 messages in this topic