Moodle webservices proxy with WSDL capability, any thoughts?

Moodle webservices proxy with WSDL capability, any thoughts?

by Bill Antonia -
Number of replies: 4

Hi,

In thread http://moodle.org/mod/forum/discuss.php?d=200117 I looked into the idea of creating a kind of proxy service running on Glassfish which acts as an go between between clients and Moodle webservices running on each individual Moodle server.

I've tested this locally and it works, although tested only one call so far, more operations to add.

Basically the proxy server can call your own Moodle server webservices via REST protocols which has been sent the URL, credentials, webservice function and parameters from a client which has generated its interface to the proxy server via WSDL. The WSDL generated is compliant so a range of programming languages can in effect easily call Moodle webservices in a round about way on your own server for you.

I would need to modify the Java REST library a bit as it currently uses static methods and there might be some crosstalk between threads on the proxy server, initially the library was writen to integrate systems within a single site so was not a problem.

I will probably need to use C# or C/C++ to communicate back to our MIS(SIMS) so will probably go down this route anyway and I don't want to create new libraries for these languages.

With the absence of a fully WSDL compliant service within Moodle, what do you think?

Average of ratings: -
In reply to Bill Antonia

Re: Moodle webservices proxy with WSDL capability, any thoughts?

by Bill Antonia -

Decided to go ahead with the project anyway as I do want to use other languages to access Moodle webservices and didn't want to write another language specific library. Therefore to build on what I already have written in Java and utillising the abilities of Java EE to create a WSDL for me on a Glassfish server so other languages can use these methods to access Moodle webservices.

The current project download can be found here.

Calls currently supported are, more will be created in due course:

getAllCourses
getCoursesByIds
getCourseById
createCourse (Note: not tested yet, may do today!)
getCourseContent

As it is a type of proxy server all calls require the URL in the form of:

http://moodleserver/moodlepath/webservice/rest/server.php

and the token followed by any parameters required.

Still open to any thoughts, like should the naming convention follow that in Moodle or should I make them up as I feel like? I do know this probably is an interim solution to the WSDL problem, well in my case anyway.

Attached is an example output (edited, removing names etc) from getCourseContent, run using the Glassfish in-built tester. Note though using the WSDL file, it will generate all the calls and artefacts for the programming language you are using and be able to translate this type of output into real objects to be used as you wish.

In reply to Bill Antonia

Re: Moodle webservices proxy with WSDL capability, any thoughts?

by Bill Antonia -

All the current supported methods function, the createCourse works without issues now. There is createCourses as well but I forgot to put it in the list in the earlier post.

Even created a C# client using the WSDL and read the data. I'm happy!

Average of ratings: Useful (1)
In reply to Bill Antonia

Re: Moodle webservices proxy with WSDL capability, any thoughts?

by Usman Wahid -

Could you kindly share the C# Client? It would be a real help.

In reply to Usman Wahid

Re: Moodle webservices proxy with WSDL capability, any thoughts?

by Bill Antonia -

Hi Usman,

The idea of WSDL is that the artefacts for your programming language are generated automatically.  The attached file was created in Microsoft C# 2010. After importing the WSDL file and wrote the attached code, I used the debug tool to trap and confirm data had been transfered. It is not that extensive, just a proof of concept, most of my programming these days is in Java. Point of interest, much more extraneous code is required to call a Java SOAP method generated by WSDL than that of C#, but that might just be the IDE I'm using for Java, NetBeans.

Regards

Bill