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

6075"Cannot marshall Expect reference" when trying to create a SOAP::Lite Object

Expand Messages
  • brettrandall83
    Dec 8, 2007
    • 0 Attachment
      Hey all

      Fairly new to SOAP::Lite but have been using Perl for awhile. I've
      created a module called "dbtcp.pm" as an interface to the "dbtcp"
      command line utility that allows you to connect from Linux to Windows
      ODBC drivers. It uses Expect.pm to send and receive data with the
      dbtcp process. However when I run my test app, the daemon spits out:

      Cannot marshall Expect reference at /usr/share/perl5/SOAP/Lite.pm line
      2592

      My test script is (stripped down):

      =================================================
      #!/opt/local/bin/perl -w

      use strict;
      use SOAP::Lite;

      my $s =
      SOAP::Lite->uri('http://192.168.157.131/dbtcp')->proxy('http://192.168.157.131/soap/');

      my $som;
      $som = $s->call(new => '');
      my $db = $som->result;
      my $retval = $s->selectrows($db)->result;
      print "$retval\n";
      =================================================

      The dbtcp.pm module looks like:

      =================================================
      package dbtcp;

      use strict;
      use Carp;
      require Expect;

      sub new {
      # Create an object with me in it and an open dbtcp session and
      # return it to the caller
      my $self = shift;
      my $class = ref($self) || $self;
      my $exp = new Expect;
      $exp->raw_pty(1);
      $exp->spawn("/usr/bin/dbtcp DSN=db 192.168.157.130") or die("Cannot
      spawn expect: $!");
      $exp->expect(5,"dbtcp>");
      # Command is now ready and waiting for commands
      bless{_expect => $exp} => $class;
      }

      sub selectrows {
      my $self = shift;
      $self->{_expect}->send("SELECT * FROM data\n");
      $self->{_expect}->expect('5',"dbtcp>");
      my $prior = $self->{_expect}->before;
      my ($numrows) = ($prior =~ /Rows: (.+)/g);
      return "$numrows rows were selected";
      }
      =================================================

      The "cannot marshall" error happens right when I call the "new"
      function. The object appears to be created as expected and the
      connection is initiated, but then when I try and use that object
      again, the selectrows() sub never gets called, presumably to do with
      whatever the "cannot marshall" error is.

      Does anyone know if I'm missing something, or if what I'm trying is
      impossible? I basically want to keep an Expect session running for the
      life of the object... Simple in concept but a bit more work than I
      thought getting it working.

      Thanks in advance

      Brett.