XML-RPC from external application

XML-RPC from external application

by madhu b -
Number of replies: 2
Hi All,

I am trying to connect to Moodle using xml-rpc. I have written a xmlrpc Java client to retrieve some information from my moodle installation.
I get an error saying:
org.apache.xmlrpc.XmlRpcException: Authorisation failed: the mnet session does not exist.
when i make a call to auth/mnet/auth.php/user_authorise().

Please throw some light to solve this problem. I am not getting how to set up the mnet session or should I call some rpc which sets up the mnet session?

Also kindly tell me how to pass parameters to these methods through xmlrpc, as
when I make a call to rpcs such as
system/listServices(),
enrol/mnet/enrol.php/available_courses() and
auth/mnet/auth.php/fetch_theme_info() I am getting the required results. These methods dont require any parameters. But others which require input parameters, return error when I call them. [Eg: enrol/mnet/enrol.php/user_enrolments(), enrol/mnet/enrol.php/enrol_user() etc,]

I have enabled moodle networking in admin->users->Authentication->Manage Authentication
and in admin->Networking I have enabled networking and have also added the remote host I want to connect from in the admin->networking-> xml rpc hosts.

Many thanks in advance,
Madhu
Average of ratings: -
In reply to madhu b

Re: XML-RPC from external application

by Hubert Chathi -
There is some information about how the login process works in MNet in the MNet Protocol wiki page, which (kind of) explains where the session comes from. (Feel free to improve the documentation! wink )

Passing parameters through XMLRPC depends on the XMLRPC library you're using; your XMLRPC library should have some way to pass parameters.
In reply to Hubert Chathi

Re: XML-RPC from external application

by madhu b -
Thank you Hubert!

I went through the MNet protocol wikipage. It looks like both the IdP and SP should be moodles. Or do I have to create similar methods at same urls so that the SP(moodle in my case) can call IdP (my application - java web app / not moodle) for session and user verification?
{
  1. SP calls "auth/mnet/auth.php/user_authorise" on IdP via XML-RPC with token and user's useragent string as parameters
  2. IdP verifies MNet session and returns user data
  3. SP may fetch additional data from IdP, add user to its own DB, update enrolments on IdP, etc.
}
Please correct me if I am wrong in interpreting the mnet document.

About passing params, I am able to pass params to moodle.

Thank You