I've been using Win32::Taskscheduler for a bit now and it has always served me well. Recently I put some of the scheduler code into a package that gets instantiated by a soap 'wrapper' . Now when I call Win32::Taskscheduler->New() I get an undefined return value.

use HTTP::Daemon::SSL; use HTTP::Status; use SOAP::Lite; use SOAP::Transport::HTTP; use auth; # Make sure you have a certs/ directory with "server-cert.pem" # and "server-key.pem" in it before running this! my $daemon = HTTP::Daemon::SSL->new(LocalPort => 8001) || die "Can't start SSH Daemon. $!\n"; my $soap = SOAP::Transport::HTTP::Server -> new ( ) -> dispatch_to(qw(auth)); print "Please contact me at: <URL:", $daemon->url, ">\n"; while (my $conn = $daemon->accept) { while (my $request = $conn->get_request) { my $req = $request->{_headers}{soapaction}; $soap->request($request); $soap->handle(); my $response = $soap->response(); $conn->send_response($response); } $conn->close; undef($conn); }


My task code is:
package auth; use strict; use Win32::TaskScheduler; sub new { my $pkg = shift; my $self = {}; bless ($self, $pkg); return $self; } sub getTaskInfo { my $self = shift; my $scheduler = Win32::TaskScheduler->New(); die "not defined" if ( !defined( $scheduler )); my %tasks; foreach my $tsk ($scheduler->Enum()) { $scheduler->Activate($tsk); substr($tsk,-4,4) = ''; $tasks{$tsk}{'status'} = -1; $scheduler->GetStatus($tasks{$tsk}{status}); $tasks{$tsk}{'code'} = -1; $scheduler->GetExitCode($tasks{$tsk}{code}); $tasks{$tsk}{'owner'} = $scheduler->GetAccountInformation(); my ($ms, $sec, $min, $hour, $day, $dayofweek, $month, $year) = + $scheduler->GetMostRecentRunTime(); $tasks{$tsk}{'last_ran'} = sprintf "%04d%02d%02d%02d%02d%02d", + $year, $month, $day, $hour, $min, $sec; ($ms, $sec, $min, $hour, $day, $dayofweek, $month, $year) = $s +cheduler->GetNextRunTime(); $tasks{$tsk}{'next_run'} = sprintf "%04d%02d%02d%02d%02d%02d", + $year, $month, $day, $hour, $min, $sec; } return %tasks; }


Its something I'm doing wrong with the SOAP wrapper code. I can instantiate and call this proc from a non-soap app and it works fine.

I looked into the 'New' method in TaskScheduler.xs. Its failing on CoCreateInstance or CoInitialize though I don't understand why.

Suggestions?

In reply to win32::taskscheduler - failure from New()? by ethrbunny

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.