Created
November 24, 2010 08:52
-
-
Save nfabre/713350 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Vmware\Soap; | |
/** | |
* @author Nicolas Fabre | |
*/ | |
class Client extends \SoapClient { | |
/** | |
* Performs SOAP request over HTTP. | |
* | |
* @see http://geauxvirtual.wordpress.com/2010/10/07/using-php5-soap-with-vsphere-api/ | |
* @param string $request The XML SOAP request. | |
* @param string $location The URL to request. | |
* @param string $action The SOAP action. | |
* @param int $version The SOAP version. | |
* @param int $one_way If one_way is set to 1, this method returns nothing. Use this where a response is not expected. | |
* @return string The XML SOAP response | |
*/ | |
public function __doRequest($request,$location,$action, $version, $one_way=0) { | |
/** | |
* PHP5 SOAP function sets the type of the SOAP message as "xsi:type". | |
* The vSphere API expects a type of just "type" | |
*/ | |
$request = str_replace("xsi:", "", $request); | |
return parent::__doRequest($request, $location, $action, $version); | |
} | |
} | |
// Utilisation de notre class | |
$connection = new Vmware\Soap\Client("https://<ip>/sdk/vimService.wsdl", | |
array( | |
"trace" => 1, | |
"location"=>"https://<ip>/sdk/" | |
) | |
); | |
// Preparation des parametres a passer a la methode | |
$soapMessage = array( | |
"_this" => new SoapVar("ServiceInstance", XSD_STRING, "ServiceInstance") | |
); | |
// Appel de la methode "RetrieveServiceContent" | |
$result = $connection->RetrieveServiceContent($soapMessage); | |
// Affichage du resultat ... et ca marche | |
var_dump($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment