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

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

Expand Messages
  • brettrandall83
    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
    Message 1 of 1 , Dec 8, 2007
      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

      My test script is (stripped down):

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

      use strict;
      use SOAP::Lite;

      my $s =

      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->spawn("/usr/bin/dbtcp DSN=db") or die("Cannot
      spawn expect: $!");
      # Command is now ready and waiting for commands
      bless{_expect => $exp} => $class;

      sub selectrows {
      my $self = shift;
      $self->{_expect}->send("SELECT * FROM data\n");
      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

    Your message has been successfully submitted and would be delivered to recipients shortly.