16-08-2007, 07:54
|
#1
|
|
Anyone can play guitar
Join Date: Jun 2003
Location: London way
Age: 37
Services: Women for money
Posts: 8,023
|
Any Perl Experts?
Hi,
I'm looking for a sample of perl code that will show usage of an xml-rpc client, making a call, but (and this is the bit I've got problems with) allowing custom cookies to be passed into the request.
I've done it in Java, and I've done it in Python - but my perl knowledge is limited....
Thanks
__________________
Cheap Domain Name Registration
And this is not my face, and this is not my life
And there is not a single thing here I can recognize
And this is all a dream, and none of you are real
|
|
|
16-08-2007, 10:15
|
#2
|
|
Inactive
Join Date: Oct 2006
Posts: 1,604
|
Re: Any Perl Experts?
xml-rpc : You wanna use SOAP ?
ok maybe this
http://www.blackperl.com/RPC::XML/
install the module...
perldoc RPC::XML
and away you go
|
|
|
16-08-2007, 10:42
|
#3
|
|
Anyone can play guitar
Join Date: Jun 2003
Location: London way
Age: 37
Services: Women for money
Posts: 8,023
|
Re: Any Perl Experts?
Quote:
Originally Posted by CrC-3rr0r
xml-rpc : You wanna use SOAP ?
|
No, I want to use XML-RPC - which is different to soap
Quote:
Originally Posted by CrC-3rr0r
|
Yep, I can do that - but what I am looking for is an example of a client call, passing in a custom cookie - since by default xmlrpc doesn't really have a standard way of dealing with extra cookies in the request, so each implementation of it has it's own brand of hack to do it - as I say I've got it working java and python, but no idea for perl,,,,
__________________
Cheap Domain Name Registration
And this is not my face, and this is not my life
And there is not a single thing here I can recognize
And this is all a dream, and none of you are real
|
|
|
16-08-2007, 10:52
|
#4
|
|
Inactive
Join Date: Oct 2006
Posts: 1,604
|
Re: Any Perl Experts?
Quote:
Originally Posted by Mr_love_monkey
Yep, I can do that - but what I am looking for is an example of a client call, passing in a custom cookie - since by default xmlrpc doesn't really have a standard way of dealing with extra cookies in the request
|
perl -MCPAN -e shell
cpan> install RPC::XML
..
.
some blurb...
.
.
Writing /usr/lib64/perl5/site_perl/5.8.0/auto/RPC/XML/.packlist
Appending installation info to /usr/lib64/perl5/5.8.0/x86_64-linux-thread-multi/perllocal.pod
/usr/bin/make install -- OK
cpan> quit
perldoc RPC::XML
Look at the authenticate method
http://search.cpan.org/src/JALDHAR/W...ce/Advogato.pm
I dunno man, why do you want to use perl and this old has been RPC::XML ?
|
|
|
16-08-2007, 11:05
|
#5
|
|
Anyone can play guitar
Join Date: Jun 2003
Location: London way
Age: 37
Services: Women for money
Posts: 8,023
|
Re: Any Perl Experts?
Quote:
Originally Posted by CrC-3rr0r
|
Thanks I'll take a look
Quote:
Originally Posted by CrC-3rr0r
I dunno man, why do you want to use perl and this old has been RPC::XML ?
|
well, Perl wouldn't be my choice, but it has a wide user base in the bank here, and as I've provided an xml-rpc interface into the system I'm writing for them, I need to provide some examples of how to access it in as many languages as possible.
As for why xml-rpc, it's lightweight, doesn't have the irritations that soap has, and lets me do somethings I wouldn't be able to do with soap (due to our authentication model).
__________________
Cheap Domain Name Registration
And this is not my face, and this is not my life
And there is not a single thing here I can recognize
And this is all a dream, and none of you are real
|
|
|
16-08-2007, 11:34
|
#6
|
|
Inactive
Join Date: Oct 2006
Posts: 1,604
|
Re: Any Perl Experts?
Hmmmmm well I've stopped using perl prefer to do this kind of stuff over j2ee nowadays.
|
|
|
16-08-2007, 11:43
|
#7
|
|
Anyone can play guitar
Join Date: Jun 2003
Location: London way
Age: 37
Services: Women for money
Posts: 8,023
|
Re: Any Perl Experts?
Quote:
Originally Posted by CrC-3rr0r
Hmmmmm well I've stopped using perl prefer to do this kind of stuff over j2ee nowadays.
|
yeah, the serverside is all done in java, as I say, the first client was java, since the aim was to the provide a wrapper API, and then plug it into eclipse(spit!) - but as I say, perl is big here, still big in a lot of places - had IBM here the other day trying to sell us some software which is was perl based.
__________________
Cheap Domain Name Registration
And this is not my face, and this is not my life
And there is not a single thing here I can recognize
And this is all a dream, and none of you are real
|
|
|
16-08-2007, 11:50
|
#8
|
|
Inactive
Join Date: Oct 2006
Posts: 1,604
|
Re: Any Perl Experts?
Heh I'm sure we had the eclipse discussion be4 :p
I like me eclipse.
Yeh lot of banks still have that sybase/perl transact layer. Good luck with it
|
|
|
16-08-2007, 12:19
|
#9
|
|
Anyone can play guitar
Join Date: Jun 2003
Location: London way
Age: 37
Services: Women for money
Posts: 8,023
|
Re: Any Perl Experts?
Quote:
Originally Posted by CrC-3rr0r
Heh I'm sure we had the eclipse discussion be4 :p
I like me eclipse.
|
I'd like it a lot more if it didn't keep crashing on me... and plug ins are all well and good, in theory, but all it seems to do is give Joe Bloggs on the street ample oppportunity to crash my IDE with unfailing regularity...
ok, I think you're going to have to explain to me what's going on here, if you don't mind :
Code:
sub _authenticate()
{
my ($self) = @_;
my $result = $self->{'client'}->send_request('authenticate',
RPC_STRING($self->{'user'}), RPC_STRING($self->{'pass'}));
croak $result unless ref $result;
croak $result->code . ': ' . $result->string
if ref $result eq 'RPC::XML::fault';
$self->{'cookie'} = $result->value;
}
__________________
Cheap Domain Name Registration
And this is not my face, and this is not my life
And there is not a single thing here I can recognize
And this is all a dream, and none of you are real
|
|
|
16-08-2007, 13:11
|
#10
|
|
Inactive
Join Date: Oct 2006
Posts: 1,604
|
Re: Any Perl Experts?
Soz was away for lunch...
take a looksie @ perldoc RPC::XML::Client
use the following example to get up n running.
NAME
RPC::XML::Client - An XML-RPC client class
SYNOPSIS
require RPC::XML;
require RPC::XML::Client;
$cli = RPC::XML::Client->new('http://www.localhost.net/RPCSERV');
$resp = $cli->send_request('system.listMethods');
print ref $resp ? join(', ', @{$resp->value}) : "Error: $resp";
DESCRIPTION
This is an XML-RPC client built upon the RPC::XML data classes, and
---------- Post added at 14:11 ---------- Previous post was at 14:08 ----------
#!/usr/bin/perl
require RPC::XML;
require RPC::XML::Client;
$cli = RPC::XML::Client->new('http://www.localhost.net/RPCSERV');
$cli->send_request('authenticate',RPC_STRING('user'),RP C_STRING('pass'));
$resp = $cli->send_request('system.listMethods');
print ref $resp ? join(', ', @{$resp->value}) : "Error: $resp";
EDIT : I made up the authenticate line try it with and without the RPC_STRING wrapper
|
|
|
17-08-2007, 14:56
|
#11
|
|
Anyone can play guitar
Join Date: Jun 2003
Location: London way
Age: 37
Services: Women for money
Posts: 8,023
|
Re: Any Perl Experts?
Quote:
Originally Posted by CrC-3rr0r
<snip/>
$cli = RPC::XML::Client->new('http://www.localhost.net/RPCSERV');
$cli->send_request('authenticate',RPC_STRING('user'),RP C_STRING('pass'));
$resp = $cli->send_request('system.listMethods');
|
ok, got it roughly working now - your one above was showing how to pass parameters into the rpc call, which wasn't what I was looking to do just then, i needed to add in a custom cookie into the httprequest - like thus:
Code:
#!/usr/bin/perl
require RPC::XML;
require RPC::XML::Client;
require HTTP::Request;
$cli = RPC::XML::Client->new('http://myserver.com:1234/xmlrpc');
$req = $cli->request;
$req->push_header(Cookie=>'rpcUser=MlM');
$resp = $cli->simple_request('rpcServer.discoverInterface');
print ref $resp ? join(', ', @{$resp->value}) : "Error: $resp";
Thanks for your help
__________________
Cheap Domain Name Registration
And this is not my face, and this is not my life
And there is not a single thing here I can recognize
And this is all a dream, and none of you are real
|
|
|
20-08-2007, 09:36
|
#12
|
|
Inactive
Join Date: Oct 2006
Posts: 1,604
|
Re: Any Perl Experts?
Quote:
Originally Posted by Mr_love_monkey
Thanks for your help
|
Nice, I was just guessing on the auth method as I have not used the module before
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 01:29.
|