Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function convertPhpToXml($data)
 {
     $part = new MimePart($data);
     $contentId = trim($part->getHeader('Content-ID'), '<>');
     $this->soapKernel->addAttachment($part);
     return sprintf('<%s href="%s"/>', $this->getTypeName(), 'cid:' . $contentId);
 }
Пример #2
0
 /**
  * Modify the given request XML.
  *
  * @param \BeSimple\SoapCommon\SoapRequest $request SOAP request
  *
  * @return void
  */
 public function filterRequest(SoapRequest $request)
 {
     // get attachments from request object
     $attachmentsToSend = $request->getAttachments();
     // build mime message if we have attachments
     if (count($attachmentsToSend) > 0) {
         $multipart = new MimeMultiPart();
         $soapPart = new MimePart($request->getContent(), 'text/xml', 'utf-8', MimePart::ENCODING_EIGHT_BIT);
         $soapVersion = $request->getVersion();
         // change content type headers for MTOM with SOAP 1.1
         if ($soapVersion == SOAP_1_1 && $this->attachmentType & Helper::ATTACHMENTS_TYPE_MTOM) {
             $multipart->setHeader('Content-Type', 'type', 'application/xop+xml');
             $multipart->setHeader('Content-Type', 'start-info', 'text/xml');
             $soapPart->setHeader('Content-Type', 'application/xop+xml');
             $soapPart->setHeader('Content-Type', 'type', 'text/xml');
         } elseif ($soapVersion == SOAP_1_2) {
             $multipart->setHeader('Content-Type', 'type', 'application/soap+xml');
             $soapPart->setHeader('Content-Type', 'application/soap+xml');
         }
         $multipart->addPart($soapPart, true);
         foreach ($attachmentsToSend as $cid => $attachment) {
             $multipart->addPart($attachment, false);
         }
         $request->setContent($multipart->getMimeMessage());
         // TODO
         $headers = $multipart->getHeadersForHttp();
         list(, $contentType) = explode(': ', $headers[0]);
         $request->setContentType($contentType);
     }
 }
Пример #3
0
 /**
  * {@inheritDoc}
  */
 public function convertPhpToXml($data)
 {
     $part = new MimePart($data);
     $contentId = trim($part->getHeader('Content-ID'), '<>');
     $this->soapKernel->addAttachment($part);
     $doc = new \DOMDocument();
     $node = $doc->createElement($this->getTypeName());
     $doc->appendChild($node);
     // add xop:Include element
     $xinclude = $doc->createElementNS(Helper::NS_XOP, Helper::PFX_XOP . ':Include');
     $xinclude->setAttribute('href', 'cid:' . $contentId);
     $node->appendChild($xinclude);
     return $doc->saveXML();
 }
Пример #4
0
 public function testGetMessagePart()
 {
     $p = new Part('<xml1/>', 'text/xml', 'utf-8', Part::ENCODING_BINARY, 'urn:myuniqueresource');
     $messagePart = "Content-Type: text/xml; charset=utf-8\r\n" . "Content-Transfer-Encoding: binary\r\n" . "Content-ID: <urn:myuniqueresource>\r\n" . "\r\n" . "<xml1/>";
     $this->assertEquals($messagePart, $p->getMessagePart());
 }
Пример #5
0
 /**
  * Add attachment.
  *
  * @param \BeSimple\SoapCommon\Mime\Part $attachment New attachment
  *
  * @return void
  */
 public function addAttachment(MimePart $attachment)
 {
     $contentId = trim($attachment->getHeader('Content-ID'), '<>');
     $this->attachments[$contentId] = $attachment;
 }
Пример #6
0
 public function testAddGetPart()
 {
     $mp = new MultiPart();
     $p = new Part('test');
     $p->setHeader('Content-ID', 'mycontentid');
     $mp->addPart($p);
     $this->assertEquals($p, $mp->getPart('mycontentid'));
 }
Пример #7
0
 /**
  * Add new part to MIME message.
  *
  * @param \BeSimple\SoapCommon\Mime\Part $part   Part that is added
  * @param boolean                        $isMain Is the given part the main part of mime message
  *
  * @return void
  */
 public function addPart(Part $part, $isMain = false)
 {
     $contentId = trim($part->getHeader('Content-ID'), '<>');
     if ($isMain === true) {
         $this->mainPartContentId = $contentId;
         $this->setHeader('Content-Type', 'start', $part->getHeader('Content-ID'));
     }
     $this->parts[$contentId] = $part;
 }