summaryrefslogtreecommitdiffstats
path: root/library/SSRS/Soap/ServerException.php
blob: 3ffce47d037cda0c9a0542d6c83679a547b5c207 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
    }

}