2016-11-02 16:08:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the BeSimpleSoapClient.
|
|
|
|
*
|
|
|
|
* (c) Christian Kerl <christian-kerl@web.de>
|
|
|
|
* (c) Francis Besset <francis.besset@gmail.com>
|
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace BeSimple\SoapServer;
|
|
|
|
|
2016-11-08 15:42:52 +01:00
|
|
|
use BeSimple\SoapBundle\Soap\SoapAttachment;
|
2017-02-03 15:22:37 +01:00
|
|
|
use BeSimple\SoapClient\SoapResponseTracingData;
|
|
|
|
use BeSimple\SoapCommon\Mime\PartFactory;
|
2016-11-02 16:08:21 +01:00
|
|
|
use BeSimple\SoapCommon\SoapMessage;
|
|
|
|
|
|
|
|
class SoapResponseFactory
|
|
|
|
{
|
|
|
|
/**
|
2017-02-03 15:22:37 +01:00
|
|
|
* Factory function for SoapServer\SoapResponse.
|
2016-11-02 16:08:21 +01:00
|
|
|
*
|
2017-02-03 15:22:37 +01:00
|
|
|
* @param string $content Content
|
|
|
|
* @param string $location Location
|
|
|
|
* @param string $action SOAP action
|
|
|
|
* @param string $version SOAP version
|
|
|
|
* @param SoapAttachment[] $attachments SOAP attachments
|
2016-11-02 16:08:21 +01:00
|
|
|
*
|
|
|
|
* @return SoapResponse
|
|
|
|
*/
|
2017-02-03 15:22:37 +01:00
|
|
|
public static function create(
|
|
|
|
$content,
|
|
|
|
$location,
|
|
|
|
$action,
|
|
|
|
$version,
|
|
|
|
array $attachments = []
|
|
|
|
) {
|
2016-11-02 16:08:21 +01:00
|
|
|
$response = new SoapResponse();
|
|
|
|
$response->setContent($content);
|
|
|
|
$response->setLocation($location);
|
|
|
|
$response->setAction($action);
|
|
|
|
$response->setVersion($version);
|
|
|
|
$contentType = SoapMessage::getContentTypeForVersion($version);
|
|
|
|
$response->setContentType($contentType);
|
2016-11-08 15:42:52 +01:00
|
|
|
if (count($attachments) > 0) {
|
|
|
|
$response->setAttachments(
|
2017-02-03 15:22:37 +01:00
|
|
|
PartFactory::createAttachmentParts($attachments)
|
2016-11-08 15:42:52 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-11-02 16:08:21 +01:00
|
|
|
return $response;
|
|
|
|
}
|
2016-11-08 15:42:52 +01:00
|
|
|
|
|
|
|
/**
|
2017-02-03 15:22:37 +01:00
|
|
|
* Factory function for SoapServer\SoapResponse.
|
|
|
|
*
|
|
|
|
* @param string $content Content
|
|
|
|
* @param string $location Location
|
|
|
|
* @param string $action SOAP action
|
|
|
|
* @param string $version SOAP version
|
|
|
|
* @param SoapResponseTracingData $tracingData Data value object suitable for tracing SOAP traffic
|
|
|
|
* @param SoapAttachment[] $attachments SOAP attachments
|
|
|
|
*
|
|
|
|
* @return SoapResponse
|
2016-11-08 15:42:52 +01:00
|
|
|
*/
|
2017-02-03 15:22:37 +01:00
|
|
|
public static function createWithTracingData(
|
|
|
|
$content,
|
|
|
|
$location,
|
|
|
|
$action,
|
|
|
|
$version,
|
|
|
|
SoapResponseTracingData $tracingData,
|
|
|
|
array $attachments = []
|
|
|
|
) {
|
|
|
|
$response = new SoapResponse();
|
|
|
|
$response->setContent($content);
|
|
|
|
$response->setLocation($location);
|
|
|
|
$response->setAction($action);
|
|
|
|
$response->setVersion($version);
|
|
|
|
$response->setTracingData($tracingData);
|
|
|
|
$contentType = SoapMessage::getContentTypeForVersion($version);
|
|
|
|
$response->setContentType($contentType);
|
|
|
|
if (count($attachments) > 0) {
|
|
|
|
$response->setAttachments(
|
|
|
|
PartFactory::createAttachmentParts($attachments)
|
2016-11-08 15:42:52 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-02-03 15:22:37 +01:00
|
|
|
return $response;
|
2016-11-08 15:42:52 +01:00
|
|
|
}
|
2016-11-02 16:08:21 +01:00
|
|
|
}
|