readme.txt 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. Webservice helper 1.5 - Readme
  2. For more information see www.jool.nl/webservicehelper/
  3. Author: David Kingma david<AT>jool<DOT>nl
  4. 1. Changelog
  5. 2. What does the webservice helper?
  6. 3. Manual
  7. 4. FAQ
  8. 6. Example
  9. 7. TODO
  10. Changelog 1.5
  11. - New Rename and prefix classes, except the WSHelper class
  12. - Support literal and encoded services
  13. - Use new native get ReflectionProperty::getDocComment()
  14. - Catch any exceptions only in the service.php (and rethrow a soapFault with the exception
  15. message) to allow for better error handling and database transaction revert
  16. - Revamp the template system to use XSLTemplate class
  17. - All IPReflection classes now support annotations
  18. - Fix bug with parameter order
  19. - Fix bug with method calls without parameters (Shawn Cook)
  20. - Fix: don't create a reflection object, unless it's needed for WSDL generation
  21. or documentation
  22. - Use native ob_gz output compression callback
  23. - Support persistence settings
  24. -- 1. What does the webservice helper?
  25. The webservice helper does what the name says: helping you making a php class
  26. available as webservice. It generates the documentation, the webservice
  27. description file (WSDL) and handles errorhandling. It consists of three parts:
  28. * extension of the PHP reflection classes to also parse the comments for
  29. information on parameter info and return values. The documentation and WSDL
  30. are generated from these classes.(see also documentation.php as an example)
  31. * extension to the PHP SOAP implementation. It catches all normal exceptions
  32. and allows typehints in the webservice methods. (ie. saveContact(contact $contact))
  33. -- 2. Manual
  34. So how do you create your own webservice. As an example we create a webservice to
  35. add and show contacts. First you create a class called contactManager in the
  36. /lib/data_objects with the public functions getContacts(), saveContact(contact
  37. $contact) and newContact(). To let the Webservice helper know what the parameters
  38. and return values of each method are we put a comment in front of each method
  39. specifying the parameters and return types. For example:
  40. /**
  41. * This method saves the given contact
  42. * @return contact[] Array with all the contacts
  43. */
  44. public function getContacts(){}
  45. /**
  46. * This method saves the given contact
  47. * @param contact The contact to save
  48. * @return void
  49. */
  50. public function saveContact(contact $contact){}
  51. /**
  52. * This method saves the given contact
  53. * @return contact A new contact template
  54. */
  55. public function newContact(){}
  56. We used the contact type as a return value for newContact() and getContacts() so we
  57. need to define what a contact looks like. For that we create a class called contact:
  58. class contact{
  59. /** @var string */
  60. public $name;
  61. /** @var string */
  62. public $address;
  63. }
  64. Since string is (just as boolean and int) a known datatype we don't need to specify it
  65. any further.
  66. The last thing we need to do to finish our webservice is to tell the webservice that de
  67. contactManager class is an allowed webservice and that contact is an allowed data-
  68. structure (for documentation purpose and classmap). In the config.php you add "contactmanager" to
  69. the WSClasses array and add "contact" to the WSStructures array.
  70. You can now view the service documentation at /service.php and the wsdl at
  71. /service.php?class=contactManager&wsdl
  72. -- 3. FAQ
  73. * My function doesn't showup in the documentation nor the WSDL file?
  74. Please check if it's a public function and it doesn't start with '__'
  75. * It doesn't work!
  76. - Do you see any warnings in the generated documentation? Fix them
  77. - Check case sensitivity of class names
  78. - Did you check the javaconsole to see if anything goes wrong?
  79. - Tried cleaning the wsdl cache in the WSDL cache directory?
  80. - Did you check the WSDL url in the client?
  81. * Can I use the webservice helper in my own project?
  82. Yes you can use it under the terms of LGPL 2.1 and send me mail about the project
  83. and with any codechanges.
  84. -- 5. example
  85. See /service.php?class=contactManager and the tests folder
  86. -- 6. TODO
  87. * Document and publish the javascript client
  88. * Making a better cache mechanism for the WSDL files and documentation
  89. * XML signature / XML encryption
  90. * Make it possible to put the type info in a seperate xsd file and include that file in the wsdl definitions
  91. * Enable multidimensional array definitions, for example giving: @param contact[][]