Hello Mj1234,

You have been long enough on this forum to know how you should post a question and expect an answer. You can not post part of your code and expect as to assist you. Having said that, sample of server code taken from SimpleXMLRPCServer Example.

server.py

from SimpleXMLRPCServer import SimpleXMLRPCServer from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler # Restrict to a particular path. class RequestHandler(SimpleXMLRPCRequestHandler): rpc_paths = ('/RPC2',) # Create server server = SimpleXMLRPCServer(("localhost", 8000), requestHandler=RequestHandler) server.register_introspection_functions() # Register pow() function; this will use the value of # pow.__name__ as the name, which is just 'pow'. server.register_function(pow) # Run the server's main loop server.serve_forever()

It is easy to see that you have skipped some parts like wrong import of modules and defining your method/function on the script that you provide us sample of code.

Moving to the client side, based on the script above.

client.pl

#!/usr/bin/perl use strict; use warnings; use Frontier::Client; my $server_url = 'http://localhost:8000/RPC2'; my $server = Frontier::Client->new(url => $server_url); # Call the remote server and get our result. my $result = $server->call('pow', 2, 3); print "Pow: $result\n"; __END__ perl client.pl Pow: 8

Sample of python script client:

client.py

import xmlrpclib s = xmlrpclib.ServerProxy('http://localhost:8000') print "Pow: {}".format(s.pow(2, 3))

Run the sample of code and you will see the same output.

Also here is a very nice tutorial Using XML-RPC with Perl, regarding XML-RPC in a variety of languages including Perl.

Update: Not to forget here is the code for server in Perl also, tested with both client and server in Python and Perl.

server.pl

#!/usr/bin/perl use strict; use warnings; use Frontier::Daemon; sub pow { my ($x, $y) = @_; return $x ** $y; } # Call me as http://localhost:8000/RPC2 my $methods = { 'pow' => \&pow, }; Frontier::Daemon->new( LocalPort => 8000, methods => $methods) or die "Couldn't start HTTP server: $!";

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: Perl RPC Client by thanos1983
in thread Perl RPC Client by Mj1234

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.