コード例 #1
0
 /**
  * Handles the response
  *
  * @param string $soapMessage The response
  *
  * @throws Exception
  *
  * @return \SimpleXMLElement The response XML <Body> tag
  */
 private function handleResponse($soapMessage)
 {
     // No message is returned, something went wrong, throw a Soap exception which
     // means there was an error communicating with the soap webservice`
     if (!$soapMessage) {
         throw new SoapException($this->getCurlClient()->getError(), $this->getCurlClient()->getErrorNr());
     }
     // Construct a SimpleXMLElement from the message
     $xml = new \SimpleXMLElement($soapMessage);
     if (self::$debug === true) {
         echo "<h2>RESPONSE</h2></hr />";
         echo '<pre>', htmlentities(self::formatXml($xml->asXml())), '</pre>';
     }
     // If the response is a Fault throw a webservice exception
     $fault = $xml->children('soap', true)->Body->Fault;
     if ($fault) {
         throw self::getExceptionForFault($fault->Detail->children()->Error->Code->__toString());
     }
     // Return the body element from the XML
     return $xml->children('soap', true)->Body;
 }