Difference between revisions of "PHPCommandLineSoap"
From Rackspace Email & Apps API
(New page: This will work with pre-compiled SOAP and has been tested with PHP 5.2.1. Setting the $debug variable to true and running the commandline tool will display the request headers and message...) |
(No difference)
|
Latest revision as of 15:58, 25 August 2008
This will work with pre-compiled SOAP and has been tested with PHP 5.2.1. Setting the $debug variable to true and running the commandline tool will display the request headers and message body.
<?php $debug = false; if ((count($argv)==1)||($argv[1]=="-h")||($arg[1]=="--help")) { echo "Written by Kirk Averett for Webmail.us in 2007\n"; echo "\n"; echo "Usage: php soapinterface.php wsdl function param1 param2 param3 ...\n"; echo "\n"; echo "For example:\n"; echo " php soapinterface.php https://secure.webmail.us/mail4/soap/soap_server.php?wsdl ping Hello\n"; echo "\n"; echo "Produces:\n"; echo "Hello\n"; echo "\n"; echo "Another example:\n"; echo " php soapinterface.php https://admin.webmail.us/excedentsoap/excedentsoap.wsdl GetUserMailForward /\n"; echo " admin password somedomain someuser '' 0\n"; echo "\n"; echo "Produces:\n"; echo "Array\n"; echo "(\n"; echo " [Result] => 1\n"; echo " [ForwardEmailString] => someforward\n"; echo " [SaveCopy] => 0\n"; echo ")\n"; echo "\n"; exit; } array_shift($argv); $wsdl = array_shift($argv); $client = new SoapClient($wsdl, array('trace' => true, 'exceptions' => true)) or die('Counldn\'t initilize SOAP client\n'); $func = array_shift($argv); $res = $client->__soapCall($func,$argv); print_r($res); echo "\n"; if ($debug) { $headers = $client->__getLastRequestHeaders(); echo "---------- Headers from the request:\n"; print_r($headers); echo "\n"; $request = $client->__getLastRequest(); echo "---------- Body of the request:\n"; print_r($request); echo "\n"; } ?>