/** * 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); } }