XML-RPC Server with Perl


  • The URL given by the client needs to be http://some_url.com/RPC2
  • The server runs at non http port. So if you are connecting from diff network, then you will need firewall ports open to this port.

    
    #!/use/bin/perl  
    
        
    use Frontier::Daemon;
      
    sub sumAndDifference {
        my ($x, $y) = @_;
        return {'sum' => $x + $y, 'difference' => $x - $y};
    }
        
    # Call me as http://localhost:8080/RPC2
    $methods = {'sample.sumAndDifference' => \&sumAndDifference};
    Frontier::Daemon->new(LocalPort => 8080, methods => $methods)
         or die "Couldn't start HTTP server: $!";