How does it works:
1. The WS client requests a specific WSDL, containing the authentication method descripiton. This authentication method returns a session token.
2. Then the WS client request another specific WSDL. The session token and the name of the function location must be included in the WSDL URL. A web service client prgrammer can know all function locations from the /moodle/webservice/documentation.php?protocol=soap. This file generates a documentation to how to use the web services, and also a list of all web service functions and their locations into Moodle.
3. The WS client calls a web service function
In order to create a PHP client it is really easy to use Zend_Soap_client. Most of the automatic client generators (Java, .Net,...) doesn't work yet with the current Zend framework version 1.7. Zend team says it will be working with the 1.8 version of the Zend framework (mid 2009). It's why the documentation.php should give the WS client programmer all information about param/return structure.
I get an error when I access the zend_soap_client.php in the ..webservice\soap\testclient directory. The webpage returned says that the webservices are enabled, the soap protocol is enabled, and the token is int(456) but then an exception occurs:
SOAP-ERROR: Parsing WSDL: Couldn't load from '.....token=456&classpath=user&wsdl'
Any idea why this is happening?
You should be able to run them again.
Thanks for updating the clients - I'm still having the same problem, however. To make sure I have a clean test environment, I installed a new WAMP environment on a new machine and unfortunately I get the same error. Here is the info on the web page that is returned when accessing the zend_soap_client.php in the ..webservice\soap\testclient directory:
Soap test client:
Web services enable: OK
soap protocol enable: OK
Exception - SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost/atilms/webservice/soap/server.php?token=456&classpath=user&wsdl' : failed to load external entity "http://localhost/atilms/webservice/soap/server.php?token=456&classpath=user&wsdl"
Could this be a configuration issue?
It's now working! Apparently you have to define a user 'wsuser' with password 'wspassword' that has the moodle/user:viewdetails capability for the test client to run smoothly on the site it accesses. It's definitely a challenge debugging across the soap layer...
We developed a client app written with Visual Studio 2008 that uses the OK Tech webservices layer and it works great - very stable and we use it daily to administer our moodle site. I want to explore using VS 2008 to access the new webservices layer you're developing for Moodle 2.0, so that's my next step.
thanks for all your effort.
The web service authentication is still going to be implemented by Petr.
Can you tell me more about the error you had? I'd like to reproduce it in order to make client debugging easier. I could not get the same error message.
I also found out that the SOAP server didn't register specific "moodle_exception". So all exceptions were always returned as "unknown error" by the SOAP server. I'll commit the fix this avo. The error messages will be more clear.
I'll be happy to help you for developing your SOAP client for Moodle 2.0. Don't hesitate to post any comments you have about the Moodle 2.0 web services, it's better to know what is wrong now
I could not reproduce the error message "SOAP ERROR: Parsing ..." that was returned previously, once I added the 'wsuser' account to the test database. Even when I removed 'wsuser' from the database to try to duplicate the error message, only the 'Exception - Unknown error' reports back...
Your latest update works great - the SoapFault Exception messages are now reporting the details!
I am looking for a .NET client code example that implements a client webservice function call to the Zend_Soap layer, and I have not found one yet. If you know where I can find some documentation that shows how to do this, please let me know. Once I get the first call working, I'll be able to test the rest of the functions using .NET.
I didn't test the last Zend_SOAP 1.8 library but with the current one used in Moodle HEAD, JAVA and .Net automatic client generators don't work. Something was wrong is the WSDL generation, I'll check if it's been fixed in the last version of Zend_SOAP.
I'll also have a look for writing a JAVA client today (I guess if it works in Java it should be working ). I come back to you soon.
I've just tried Zend Framework 1.8 with Moodle 2.0, and got the same WSDL generated.
I'm struggling yet to make a sample Java client. By default the generated WSDL into Moodle will not work with any Java client generator. I succeed to make Netbeans generate a Java client after changing some settings of the Zend_soap server. I'm going to open a new post for that, maybe someone will have some clue.
Could you share what Zend-soap settings you've changed?
Excuse my ignorance if this is a simple question. I haven't played with php for about 9 years.