Accessing the SSRS SOAP API from perl - perl

I would like to know if its possible to access the SSRS SOAP API from Perl. I have written some C# applications that use SSRS, but most of my code base is in Perl running on Unix. I am not really familiar with SOAP at all.
I would like to know if its even possible, and if it is, I would like to know how to code up the following example int perl:
http://msdn.microsoft.com/en-us/library/reportservice2010.reportingservice2010.listchildren.aspx
Thanks
EDIT:
I am only looking for an example of how to connect and execute a function.
In essence, I am looking on how to write the following(simplified) C# code in Perl?
ReportingService2010 rs = new ReportingService2010();
rs.Url = "<server adress here>";
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
CatalogItem[] items = rs.ListChildren("/", true);
foreach (CatalogItem i in items){
Console.WriteLine(i.Name);
}

I know 2 way for it
SOAP::Lite https://github.com/mishin/presentation/blob/master/4_trans/02_SOAP_Lite.pl
XMLRPC::Lite https://github.com/mishin/presentation/blob/master/4_trans/03_2_XMLRPC_Lite.pl

Related

How to get result from QQuickWebEngineView::runJavaScript

I'm trying to execute javascript on QQuickWebEngineView object in c++ and get returned value. In QML it's easy
view.runJavaScript("document.documentElement.outerHTML", function(result){//do smth})
in c++ method signature for executing js is this:
void runJavaScript(const QString&, const QJSValue & = QJSValue());
and I believe I could use QJSValue to get returned data, but I'm not finding anything on how to use it... maybe someone has an example of how to use QJSValue here. Thanks.

Dancer2 strange behaviour on get protocol

I'm building a webapp using dancer2 as backend tool. I've implemented the main method as follow:
#!/usr/bin/env perl
use Dancer2;
get '/mything/:text' => sub {
my #myArray = ("");
# Fill the array with DB data;
return join "<br>", #myArray;
};
dance;
Everything is fine until the second time get method is used. Insted of #myArray being empty, its filled with the from the first execution.
As a dirty fix, I initialize #myArray to ("") at the end of the method, but I think that is ugly. Have you any experience on this?
To test this, I expanded your code into the following:
#!/usr/bin/env perl
use Dancer2;
get '/mything/:text' => sub {
my #myArray = localtime;
# Fill the array with DB data;
return join "<br>", #myArray;
};
dance;
Using localtime() was the easiest way I could think of to get a (slightly) different array each time I make a request (assume I don't make more than one request a second).
And that works exactly as I expected. I run plackup app.psgi and visit http://localhost:5000/mything/foo and I see the array I expect. When I refresh the page I get a different array.
So Dancer works as I would expect it to. If you're seeing different behaviour, it's because you're doing something different. And we can't really help you to work out what that is until we see more of your code.
Problem was related to not using perl in strict mode. The code as it was, was working properly in OSX 11.1 but not in Ubuntu 16.04. So after some tests, I found that some variables that I use to fill the array from the DB weren't properly initialized. After initialize them, everything is working as it should in OSX and Ubuntu.

Use existing Firefox session in Selenium and Perl

I have existing Firefox session with appropriate login data to interesting site. Now I want to use it with Selenium and Perl.
I am using this code:
my $driver = Selenium::Remote::Driver->new;
$driver->get("http://www.google.com");
$driver->find_element('q','name')->send_keys("Hello WebDriver!");
print $driver->get_title() . "\n";
But this code opens new blank session of Firefox.
How can I use my existing session with already set up cookies?
You want to specify a Firefox profile to use.
In Java, it'd be something like this...
ProfilesIni profile = new ProfilesIni();
FirefoxProfile firefoxProfile = profile.getProfile("Default"); // might need to switch this around depending on what it actually is named.
WebDriver driver = new FirefoxDriver(firefoxProfile);
(credit to this answer for the pseudo-code)
I think you can try with this option in perl driver.
my $handles = $driver->get_window_handles;
$driver->switch_to_window($handles->[1]);
$driver->close;
$driver->switch_to_window($handles->[0]);
I didn't use it, but may be it will help you!
For more information, please refer to this site.
https://metacpan.org/pod/Selenium::Remote::Driver

Perl WWW:Mechanize/HTML:TokeParser and following/storing URL from href attr

i am making some good progress with Perl due to the help on this site but i've run into a problem. One of the pages i was scraping from has changed and i can't figure out how to get to it now. What i want to do is store a link to each page i want to get to. The problem is that these links are inside the a href attribute tags in the source code and i have no idea how to extract them. Could anyone help me?
the links i need are from line 316 to 354 of this page(source code) http://www.soccerbase.com/teams/home.sd
i need to basically extract the links to variables for use in my other scripts. As mentioned i am using WWW::Mechanize and HTML::TokeParser, hopefully there are methods within these that i can use but can't currently figure out. Thanks in advance!
See method find_all_links in WWW::Mechanize. No need to bother manually with the parser. You probably want to relax the regex so that you get all ~1000 possible teams at once.
use WWW::Mechanize qw();
my $w = WWW::Mechanize->new;
$w->get('http://www.soccerbase.com/teams/home.sd');
for my $link ($w->find_all_links(url_regex => qr/comp_id=1\b/)) {
# 20 instances of WWW::Mechanize::Link
printf "URL=%s\tTeam=%s\n", $link->url_abs, $link->text
}
URL=http://www.soccerbase.com/tournaments/tournament.sd?comp_id=1 Team=Premier League
URL=http://www.soccerbase.com/teams/team.sd?team_id=142&comp_id=1 Team=Arsenal
URL=http://www.soccerbase.com/teams/team.sd?team_id=154&comp_id=1 Team=Aston Villa
URL=http://www.soccerbase.com/teams/team.sd?team_id=308&comp_id=1 Team=Blackburn
URL=http://www.soccerbase.com/teams/team.sd?team_id=354&comp_id=1 Team=Bolton
URL=http://www.soccerbase.com/teams/team.sd?team_id=536&comp_id=1 Team=Chelsea
URL=http://www.soccerbase.com/teams/team.sd?team_id=942&comp_id=1 Team=Everton
URL=http://www.soccerbase.com/teams/team.sd?team_id=1055&comp_id=1 Team=Fulham
URL=http://www.soccerbase.com/teams/team.sd?team_id=1563&comp_id=1 Team=Liverpool
URL=http://www.soccerbase.com/teams/team.sd?team_id=1718&comp_id=1 Team=Man City
URL=http://www.soccerbase.com/teams/team.sd?team_id=1724&comp_id=1 Team=Man Utd
URL=http://www.soccerbase.com/teams/team.sd?team_id=1823&comp_id=1 Team=Newcastle
URL=http://www.soccerbase.com/teams/team.sd?team_id=1855&comp_id=1 Team=Norwich
URL=http://www.soccerbase.com/teams/team.sd?team_id=2093&comp_id=1 Team=QPR
URL=http://www.soccerbase.com/teams/team.sd?team_id=2477&comp_id=1 Team=Stoke
URL=http://www.soccerbase.com/teams/team.sd?team_id=2493&comp_id=1 Team=Sunderland
URL=http://www.soccerbase.com/teams/team.sd?team_id=2513&comp_id=1 Team=Swansea
URL=http://www.soccerbase.com/teams/team.sd?team_id=2590&comp_id=1 Team=Tottenham
URL=http://www.soccerbase.com/teams/team.sd?team_id=2744&comp_id=1 Team=West Brom
URL=http://www.soccerbase.com/teams/team.sd?team_id=2783&comp_id=1 Team=Wigan
URL=http://www.soccerbase.com/teams/team.sd?team_id=2848&comp_id=1 Team=Wolves

Perl Authen::OATH and Google Authenticator - incompatible?

My understanding (which may obviously be wrong) is that the Authen::OATH module is compatible with the totp codes generated by the Google Authenticator App. But it doesn't work for me, whereas a similar bit of ruby code does. We're a perl shop here and it would help if anyone could point me in the right direction to save me from digging through both libraries line by line.
This ruby works compatibly:
require 'rubygems'
require 'rotp'
secret = "bqagf6ohx4rp3a67"
puts ROTP::TOTP.new(secret).now.to_s
This perl does not:
use Authen::OATH;
my $oath = Authen::OATH->new();
my $totp = $oath->totp(" bqagf6ohx4rp3a67" );
print "$totp\n";
It's not very clear from the documentation, but Authen::OATH expects the unencoded passwords to totp and hotp. If that's not an option, you could try decode_base32 from Convert::Base32
use Convert::Base32;
use Authen::OATH;
my $oath = Authen::OATH->new();
my $totp = $oath->totp( decode_base32( "bqagf6ohx4rp3a67" ) );
print "$totp\n";