diff options
author | arron.woods@gmail.com <arron.woods@gmail.com@deae1e92-32f9-c189-e222-5b9b5081a27a> | 2012-10-01 16:26:47 +0000 |
---|---|---|
committer | arron.woods@gmail.com <arron.woods@gmail.com@deae1e92-32f9-c189-e222-5b9b5081a27a> | 2012-10-01 16:26:47 +0000 |
commit | a2b0ffb492bbd963e3e5bdc8e6bedbaa0060f10f (patch) | |
tree | 446976876d2853ec1df808e2a81909b6e6693398 /library/SSRS/Soap/ServerException.php | |
parent | 7b918b07e5285cc752caf93f0558766bb24b6637 (diff) | |
download | php-ssrs-a2b0ffb492bbd963e3e5bdc8e6bedbaa0060f10f.zip php-ssrs-a2b0ffb492bbd963e3e5bdc8e6bedbaa0060f10f.tar.gz php-ssrs-a2b0ffb492bbd963e3e5bdc8e6bedbaa0060f10f.tar.bz2 |
Server exception
Diffstat (limited to 'library/SSRS/Soap/ServerException.php')
-rw-r--r-- | library/SSRS/Soap/ServerException.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/library/SSRS/Soap/ServerException.php b/library/SSRS/Soap/ServerException.php new file mode 100644 index 0000000..3ffce47 --- /dev/null +++ b/library/SSRS/Soap/ServerException.php @@ -0,0 +1,29 @@ +<?php + +class SSRS_Soap_ServerException extends Exception { + + public $faultcode; + public $faultstring; + public $faultactor; + + static function fromResponse($string) { + $xml = new SimpleXMLElement($string); + $ns = $xml->getNamespaces(true); + + $soap = $xml->children($ns['soap']); + $body = $soap->Body->children($ns['soap']); + if (isset($body->Fault)) { + $fault = $body->Fault->children(); + + $exception = new SSRS_Soap_ServerException((string) $fault->faultstring); + $exception->faultcode = (string) $fault->faultcode; + $exception->faultstring = (string) $fault->faultstring; + $exception->faultactor = (string) $fault->faultactor; + } else { + throw new SSRS_Soap_Exception('Invalid server response'); + } + + return $exception; + } + +}
\ No newline at end of file |