MimeFilters are now stateless
This commit is contained in:
@ -28,32 +28,7 @@ use BeSimple\SoapCommon\SoapResponseFilter;
|
||||
*/
|
||||
class MimeFilter implements SoapRequestFilter, SoapResponseFilter
|
||||
{
|
||||
/**
|
||||
* Attachment type.
|
||||
*
|
||||
* @var int Helper::ATTACHMENTS_TYPE_SWA | Helper::ATTACHMENTS_TYPE_MTOM
|
||||
*/
|
||||
protected $attachmentType = Helper::ATTACHMENTS_TYPE_SWA;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $attachmentType Helper::ATTACHMENTS_TYPE_SWA | Helper::ATTACHMENTS_TYPE_MTOM
|
||||
*/
|
||||
public function __construct($attachmentType)
|
||||
{
|
||||
$this->attachmentType = $attachmentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all properties to default values.
|
||||
*/
|
||||
public function resetFilter()
|
||||
{
|
||||
$this->attachmentType = Helper::ATTACHMENTS_TYPE_SWA;
|
||||
}
|
||||
|
||||
public function filterRequest(SoapRequest $request)
|
||||
public function filterRequest(SoapRequest $request, $attachmentType)
|
||||
{
|
||||
$attachmentsReceived = [];
|
||||
|
||||
@ -86,7 +61,7 @@ class MimeFilter implements SoapRequestFilter, SoapResponseFilter
|
||||
return $request;
|
||||
}
|
||||
|
||||
public function filterResponse(SoapResponse $response)
|
||||
public function filterResponse(SoapResponse $response, $attachmentType)
|
||||
{
|
||||
$attachmentsToSend = $response->getAttachments();
|
||||
if (count($attachmentsToSend) > 0) {
|
||||
@ -94,7 +69,7 @@ class MimeFilter implements SoapRequestFilter, SoapResponseFilter
|
||||
$soapPart = new MimePart($response->getContent(), 'text/xml', 'utf-8', MimePart::ENCODING_EIGHT_BIT);
|
||||
$soapVersion = $response->getVersion();
|
||||
// change content type headers for MTOM with SOAP 1.1
|
||||
if ($soapVersion == SOAP_1_1 && $this->attachmentType & Helper::ATTACHMENTS_TYPE_MTOM) {
|
||||
if ($soapVersion == SOAP_1_1 && $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');
|
||||
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace BeSimple\SoapServer;
|
||||
|
||||
use BeSimple\SoapCommon\SoapKernel;
|
||||
use BeSimple\SoapCommon\SoapRequest;
|
||||
|
||||
/**
|
||||
* SoapKernel for Server.
|
||||
*
|
||||
* @todo-critical: kill this shit
|
||||
* @author Andreas Schamberger <mail@andreass.net>
|
||||
*/
|
||||
class SoapServerKernel extends SoapKernel
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function filterRequest(SoapRequest $request, array $filters)
|
||||
{
|
||||
parent::filterRequest($request, $filters);
|
||||
|
||||
// attachments are now gone from here
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function filterResponse(SoapResponse $response)
|
||||
{
|
||||
$response->setAttachments($this->attachments);
|
||||
$this->attachments = array();
|
||||
|
||||
parent::filterResponse($response);
|
||||
}
|
||||
}
|
@ -100,7 +100,7 @@ class SoapServer extends \SoapServer
|
||||
private function handleSoapRequest(SoapRequest $soapRequest)
|
||||
{
|
||||
if ($this->soapOptions->hasAttachments()) {
|
||||
$soapRequest = $this->soapKernel->filterRequest($soapRequest, $this->getFilters());
|
||||
$soapRequest = $this->soapKernel->filterRequest($soapRequest, $this->getFilters(), $this->soapOptions->getAttachmentType());
|
||||
}
|
||||
|
||||
ob_start();
|
||||
@ -120,7 +120,7 @@ class SoapServer extends \SoapServer
|
||||
);
|
||||
|
||||
if ($this->soapOptions->hasAttachments()) {
|
||||
$this->soapKernel->filterResponse($soapResponse, $this->getFilters());
|
||||
$soapResponse = $this->soapKernel->filterResponse($soapResponse, $this->getFilters(), $this->soapOptions->getAttachmentType());
|
||||
}
|
||||
|
||||
return $soapResponse;
|
||||
|
Reference in New Issue
Block a user