server2.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license, |
  9. // | that is bundled with this package in the file LICENSE, and is |
  10. // | available at through the world-wide-web at |
  11. // | http://www.php.net/license/2_02.txt. |
  12. // | If you did not receive a copy of the PHP license and are unable to |
  13. // | obtain it through the world-wide-web, please send a note to |
  14. // | license@php.net so we can mail you a copy immediately. |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Shane Caraveo <Shane@Caraveo.com> |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: server2.php,v 1.1 2003/04/17 06:04:40 shane Exp $
  20. //
  21. // first, include the SOAP/Server class
  22. require_once 'SOAP/Server.php';
  23. $server = new SOAP_Server;
  24. /* tell server to translate to classes we provide if possible */
  25. $server->_auto_translation = true;
  26. /* This is a simple example of implementing a custom
  27. call handler. If you do this, the soap server will ignore
  28. objects or functions added to it, and will call your handler
  29. for **ALL** soap calls the server receives, wether the call
  30. is defined in your WSDL or not. The handler receives two
  31. arguments, the method name being called, and the arguments
  32. sent for that call.
  33. */
  34. function myCallHandler($methodname, $args)
  35. {
  36. global $soapclass;
  37. return @call_user_func_array(array($soapclass, $methodname),$args);
  38. }
  39. $server->setCallHandler('myCallHandler',false);
  40. require_once 'example_server.php';
  41. $soapclass = new SOAP_Example_Server();
  42. $server->addObjectMap($soapclass,'urn:SOAP_Example_Server');
  43. if (isset($_SERVER['REQUEST_METHOD']) &&
  44. $_SERVER['REQUEST_METHOD']=='POST') {
  45. $server->service($HTTP_RAW_POST_DATA);
  46. } else {
  47. require_once 'SOAP/Disco.php';
  48. $disco = new SOAP_DISCO_Server($server,'ServerExample');
  49. header("Content-type: text/xml");
  50. if (isset($_SERVER['QUERY_STRING']) &&
  51. strcasecmp($_SERVER['QUERY_STRING'],'wsdl')==0) {
  52. echo $disco->getWSDL();
  53. } else {
  54. echo $disco->getDISCO();
  55. }
  56. exit;
  57. }
  58. ?>