Posted By

joet3ch on 01/07/10


Tagged

php xml-rpc zend


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

netzwerktourist
Roen


Zend XML-RPC Client


 / Published in: PHP
 

  1. <?php
  2.  
  3. /**
  4.   * Example for calling XML-RPC web service
  5.   *
  6.   */
  7.  
  8. require_once 'Zend/XmlRpc/Client.php';
  9. require_once 'Zend/Http/Client.php';
  10.  
  11. try
  12. {
  13. $http_client = new Zend_Http_Client();
  14. $http_client->setAuth('<USERNAME>','<KEY>');
  15. $client = new Zend_XmlRpc_Client('<URL>');
  16. $client->setHttpClient($http_client);
  17. $proxy = $client->getProxy();
  18.  
  19. $args['arg1'] = '<arg1>';
  20. $args['arg2'] = '<arg2>';
  21. $args['arg3'] = '<arg3>';
  22.  
  23. $result = $proxy->className->methodName($args);
  24. echo $result;
  25. }
  26. catch (Zend_XmlRpc_Client_FaultException $e)
  27. {
  28. # display error details
  29. echo "<h1>Webservice Error!</h1><br /><br />";
  30. echo "<b>Date/Time:</b> ";
  31. $today = date("D M j G:i:s T Y");
  32. echo $today;
  33. echo "<br /><br /><b>Error:</b><br /><br />";
  34. echo $e->getMessage();
  35. echo "<br /><br />";
  36. echo "<b>Stack Trace:</b><br /><br />";
  37. echo $e;
  38. echo "<br /><br />";
  39. echo "<b>Dump:</b><br /><br />";
  40. print_r($e);
  41. }
  42.  
  43. ?>

Report this snippet  

You need to login to post a comment.