Вы находитесь на странице: 1из 9

Student Web Services in Moodle

Kristian Thornley Web Developer/eLearning Support Christchurch Polytechnic Institute of Technology

CPITs Current Situation

System Architecture
Over the years a number of systems have been adopted to fulfill business needs Integration is either via ODBC, CSV Extract, LDAP ..etc Some systems do not integrate and manual process is required to import/export

System Problems
Complex communication networks Duplication of information which is at varying levels of validity Duplication of functionality (e.g. LDAP Authentication) Maintenance and change management problems

User Problems
From a users point of view Inconsistent interfaces Multiple passwords required Not a seamless environment No one stop shop for information Scalability hindered

Answer
Web Services and the ESB (more on this later)

What are Web services


Primarily a means of system integration An exposure of Business Rules (APIs) Application to Application communication Not meant to be human readable

AV System Analogy
(non-service oriented architecture)

Proprietary connections (similar to ODBC types) Lack of universal standards means addition of new functionality is difficult Purchasing a new items requires that it is compatible with the proprietary connections limiting you to one brand
? ?

AV System Analogy
(service oriented architecture)

Universal RCA connection Addition of new functionality easy due to adherence to standards Purchasing a new items just requires that it is RCA compatible

RCA

RCA

Development

Architecture choice REST or SOAP


REST = Representational State Transfer More human readable Uses URLs e.g. http://moodle.cpit.ac.nz/<person>/<course>/<result> Not as easy to consume as SOAP Applications dont write themselves SOAP = Simple Object Access Protocol
In my opinion easier to write Flash and VB script can easily consume and automatically write abstractions to help program development

Structure of a Web Service


Client can be any application that can utilise Web Service protocols (SOAP, RPC) Languages and development platforms include Java, PHP, Actionscript, C++, .NET, VB script (MS Office products), Adobe PDF etc..

Client Uses References

Describes Service WSDL Imports

XSD Schema

WSDL is King
time spent here will save time in the future The WSDL and schema is the most import part of the structure Aids in compatibility Documents functions, purpose Outlines structure of request and response error Can be used by developmental Web Service abstractions to self write most of the code (VB script Web Services toolkit 2.0)

Client Uses References

Describes Service WSDL Imports

XSD Schema

PHP Web Service Options


NuSOAP PEAR Package PEAR::SOAP PHP5 Extension (SoapServer,SoapClient )

NuSOAP and PEAR::SOAP


Pros Good for non PHP5 implementations Automatic generation of WSDL Cons PEAR::SOAP still beta Automatic WSDL not as it seems, still requires definition in PHP instead of XML Ongoing support

http://pear.php.net/package/SOAP

http://sourceforge.net/projects/nusoap/

PHP5 SOAP Extension


My choice Ability to ingest external WSDL enables handwritten WSDL file for 100% compatibility with language libraries and wizards An extension of PHP5 development now inline with the core Lots of support

Implementation
In moodle

Initial Problems
Lack of crucial classes in Moodle User, Course etc And their associated functions e.g. getMyCourses(); etc Some functions areas are tightly coupled with the interface $USER is only an object

$USER $CFG

Solution
Creation of entity classes for User, Course, Quiz, Assignment Creation of Moodle-API-S service Creation of moodletypes.xsd mirror object properties Creation of Moodle-APIS.wsdl to describe service

The Future

We can learn a lot from Fedora


fedora.info The Institutional Repository (not Red Hat fedora)

Fedora has no interface All interaction with the Core is via web services The application is just a collection of web services Architecture finally allows for design patterns to be followed (e.g. Bridge, Faade) Interfaces decoupled from core API

ESB
The Enterprise Service Bus A Web Service of Web Services Forms a backbone within the institution Provides routing promoting efficient usage and allowing for redundancy Change management applied from one place flows through to all attached
ESB Controller

Fedora

HR

Moodle

Moodle

Course Programme Info

Load Balanced Authentication 1 Authentication 2

Conclusion

Developers point of view


Systems should do one thing and do it well
If youre good at making battleships, dont buy a chocolate factory (Drucker, P)

Web Services enable this by allowing developers to use other systems Business Logic thereby reducing the replication of their functionality poorly in your application Enables stepwise refinement of components outside of the main system split authentication module out of core Shortens product development leverages off previously developed APIs Concentrates development on what is new not doing what I have already done . Again!

Some Examples

Further Reading
Programming Web Services with Perl (OReilly)
Although not about PHP it does have a great section on WSDL and Perl is a great language anyway to learn

Zend PHP SOAP examples http://www.zend.com/php5/articles/php5-SOAP.php


Great working examples

Web Services - A Managers Guide (Addison Wesley).chm


Good for convincing people the benefits for development Plain Language

Вам также может понравиться