Ejemplo n.º 1
0
 /**
  * Modify the given request XML.
  *
  * @param \BeSimple\SoapCommon\SoapRequest $request SOAP request
  *
  * @return void
  */
 public function filterRequest(SoapRequest $request)
 {
     // array to store attachments
     $attachmentsRecieved = array();
     // check content type if it is a multipart mime message
     $requestContentType = $request->getContentType();
     if (false !== stripos($requestContentType, 'multipart/related')) {
         // parse mime message
         $headers = array('Content-Type' => trim($requestContentType));
         $multipart = MimeParser::parseMimeMessage($request->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());
         $request->setContent($content);
         $request->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) {
         $request->setAttachments($attachmentsRecieved);
     }
 }
Ejemplo n.º 2
0
 public function testParserWithHeaderArray()
 {
     $filename = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Fixtures/WS-I-MTOM-request_noheader.txt';
     $mimeMessage = file_get_contents($filename);
     $headers = array('Content-Type' => 'multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:0ca0e16e-feb1-426c-97d8-c4508ada5e82+id=7";start-info="application/soap+xml"', 'Content-Length' => 1941, 'Host' => '131.107.72.15', 'Expect' => '100-continue');
     $mp = Parser::parseMimeMessage($mimeMessage, $headers);
     $this->assertsForWsiMtomRequest($mp);
 }