This is part 2 of my SOAP series. In the 1. part I started with a basic example of creating a simple PHP Soap Server with the PEAR package Services_Webservice. In this part I will share complex objects between PHP and Flash.
So I basically created 3 PHP classes:
Now calling the webservice in the browser we´ll see that everything works like expected. The Webservice should serve 1 function “getAllBooks()” which returns a list of Book classes which hold an array of Bookservice_Author[] classes within its properties.

Quite simple, no? This took me less then 20 minutes. We now have a full Webservice running! Next step is to connect Flash against it and see if it can handle these complex types. Below is a little Actionscript client which makes use of the mx.services package. Not only we use the WebService class, we also add the Log class which helps you analyse WebServices.
Actionscript:- import mx.services.*;
- var bookStoreLog:Log = new Log();
- bookStoreLog.onLog = function(txt:String) {
- trace(txt);
- }
- var bookStore:WebService = new WebService(
- "http://services.dschini.org/Bookstore.php?WSDL",
- bookStoreLog);
- bookStoreAllBooks = bookStore.getAllBooks();
- bookStoreAllBooks.onResult = function(result:Object) {
- trace(result);
Truncated by Planet PHP, read more at the original (another 2262 bytes)