Example #1
0
 /**
  * {@inheritDoc}
  */
 public function filterResponse(CommonSoapResponse $response)
 {
     $response->setAttachments($this->attachments);
     $this->attachments = array();
     parent::filterResponse($response);
 }
Example #2
0
 /**
  * Modify the given response XML.
  *
  * @param \BeSimple\SoapCommon\SoapResponse $response SOAP response
  *
  * @return void
  */
 public function filterResponse(SoapResponse $response)
 {
     // array to store attachments
     $attachmentsRecieved = array();
     // check content type if it is a multipart mime message
     $responseContentType = $response->getContentType();
     if (false !== stripos($responseContentType, 'multipart/related')) {
         // parse mime message
         $headers = array('Content-Type' => trim($responseContentType));
         $multipart = MimeParser::parseMimeMessage($response->getContent(), $headers);
         // get soap payload and update SoapResponse object
         $soapPart = $multipart->getPart();
         // convert href -> myhref for external references as PHP throws exception in this case
         // http://svn.php.net/viewvc/php/php-src/branches/PHP_5_4/ext/soap/php_encoding.c?view=markup#l3436
         $content = preg_replace('/href=(?!#)/', 'myhref=', $soapPart->getContent());
         $response->setContent($content);
         $response->setContentType($soapPart->getHeader('Content-Type'));
         // store attachments
         $attachments = $multipart->getParts(false);
         foreach ($attachments as $cid => $attachment) {
             $attachmentsRecieved[$cid] = $attachment;
         }
     }
     // add attachments to response object
     if (count($attachmentsRecieved) > 0) {
         $response->setAttachments($attachmentsRecieved);
     }
 }