summaryrefslogtreecommitdiffstats
path: root/library/SSRS/Soap/ServerException.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/SSRS/Soap/ServerException.php')
-rw-r--r--library/SSRS/Soap/ServerException.php29
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