This commit is contained in:
Andreas Schamberger 2011-12-17 16:25:49 +01:00
parent ce30ccb504
commit 7de7ee9c6c
13 changed files with 83 additions and 36 deletions

View File

@ -191,6 +191,7 @@ class Helper
* Get SOAP namespace for the given $version. * Get SOAP namespace for the given $version.
* *
* @param int $version SOAP_1_1|SOAP_1_2 * @param int $version SOAP_1_1|SOAP_1_2
*
* @return string * @return string
*/ */
public static function getSoapNamespace($version) public static function getSoapNamespace($version)
@ -206,6 +207,7 @@ class Helper
* Get SOAP version from namespace URI. * Get SOAP version from namespace URI.
* *
* @param string $namespace NS_SOAP_1_1|NS_SOAP_1_2 * @param string $namespace NS_SOAP_1_1|NS_SOAP_1_2
*
* @return int SOAP_1_1|SOAP_1_2 * @return int SOAP_1_1|SOAP_1_2
*/ */
public static function getSoapVersionFromNamespace($namespace) public static function getSoapVersionFromNamespace($namespace)

View File

@ -46,6 +46,7 @@ class MultiPart extends PartHeader
* Construct new mime object. * Construct new mime object.
* *
* @param string $boundary Boundary string * @param string $boundary Boundary string
*
* @return void * @return void
*/ */
public function __construct($boundary = null) public function __construct($boundary = null)
@ -64,6 +65,7 @@ class MultiPart extends PartHeader
* Get mime message of this object (without headers). * Get mime message of this object (without headers).
* *
* @param boolean $withHeaders Returned mime message contains headers * @param boolean $withHeaders Returned mime message contains headers
*
* @return string * @return string
*/ */
public function getMimeMessage($withHeaders = false) public function getMimeMessage($withHeaders = false)
@ -106,6 +108,7 @@ class MultiPart extends PartHeader
* *
* @param \BeSimple\SoapCommon\Mime\Part $part Part that is added * @param \BeSimple\SoapCommon\Mime\Part $part Part that is added
* @param boolean $isMain Is the given part the main part of mime message * @param boolean $isMain Is the given part the main part of mime message
*
* @return void * @return void
*/ */
public function addPart(Part $part, $isMain = false) public function addPart(Part $part, $isMain = false)
@ -124,6 +127,7 @@ class MultiPart extends PartHeader
* parameter. * parameter.
* *
* @param string $contentId Content id of desired part * @param string $contentId Content id of desired part
*
* @return \BeSimple\SoapCommon\Mime\Part|null * @return \BeSimple\SoapCommon\Mime\Part|null
*/ */
public function getPart($contentId = null) public function getPart($contentId = null)
@ -141,6 +145,7 @@ class MultiPart extends PartHeader
* Get all parts. * Get all parts.
* *
* @param boolean $includeMainPart Should main part be in result set * @param boolean $includeMainPart Should main part be in result set
*
* @return array(\BeSimple\SoapCommon\Mime\Part) * @return array(\BeSimple\SoapCommon\Mime\Part)
*/ */
public function getParts($includeMainPart = false) public function getParts($includeMainPart = false)

View File

@ -24,6 +24,7 @@ class Parser
* *
* @param string $mimeMessage Mime message string * @param string $mimeMessage Mime message string
* @param array(string=>string) $headers Array of header elements (e.g. coming from http request) * @param array(string=>string) $headers Array of header elements (e.g. coming from http request)
*
* @return \BeSimple\SoapCommon\Mime\MultiPart * @return \BeSimple\SoapCommon\Mime\MultiPart
*/ */
public static function parseMimeMessage($mimeMessage, array $headers = array()) public static function parseMimeMessage($mimeMessage, array $headers = array())
@ -133,6 +134,7 @@ class Parser
* @param \BeSimple\SoapCommon\Mime\PartHeader $part Header part * @param \BeSimple\SoapCommon\Mime\PartHeader $part Header part
* @param string $headerName Header name * @param string $headerName Header name
* @param string $headerValue Header value * @param string $headerValue Header value
*
* @return null * @return null
*/ */
private static function parseContentTypeHeader(PartHeader $part, $headerName, $headerValue) private static function parseContentTypeHeader(PartHeader $part, $headerName, $headerValue)
@ -165,6 +167,7 @@ class Parser
* *
* @param \BeSimple\SoapCommon\Mime\Part $part Part to add content * @param \BeSimple\SoapCommon\Mime\Part $part Part to add content
* @param string $content Content to decode * @param string $content Content to decode
*
* @return null * @return null
*/ */
private static function decodeContent(Part $part, $content) private static function decodeContent(Part $part, $content)

View File

@ -68,6 +68,7 @@ class Part extends PartHeader
* @param string $charset Charset * @param string $charset Charset
* @param string $encoding Encoding * @param string $encoding Encoding
* @param string $contentId Content id * @param string $contentId Content id
*
* @return void * @return void
*/ */
public function __construct($content = null, $contentType = 'application/octet-stream', $charset = null, $encoding = self::ENCODING_BINARY, $contentId = null) public function __construct($content = null, $contentType = 'application/octet-stream', $charset = null, $encoding = self::ENCODING_BINARY, $contentId = null)
@ -76,7 +77,7 @@ class Part extends PartHeader
$this->setHeader('Content-Type', $contentType); $this->setHeader('Content-Type', $contentType);
if (!is_null($charset)) { if (!is_null($charset)) {
$this->setHeader('Content-Type', 'charset', $charset); $this->setHeader('Content-Type', 'charset', $charset);
} else { // if (substr($contentType, 0, 4) == 'text') { } else {
$this->setHeader('Content-Type', 'charset', 'utf-8'); $this->setHeader('Content-Type', 'charset', 'utf-8');
} }
$this->setHeader('Content-Transfer-Encoding', $encoding); $this->setHeader('Content-Transfer-Encoding', $encoding);
@ -110,6 +111,7 @@ class Part extends PartHeader
* Set mime content. * Set mime content.
* *
* @param mixed $content Content to set * @param mixed $content Content to set
*
* @return void * @return void
*/ */
public function setContent($content) public function setContent($content)

View File

@ -32,6 +32,7 @@ abstract class PartHeader
* @param string $name Header name * @param string $name Header name
* @param string $value Header value * @param string $value Header value
* @param string $subValue Is sub value? * @param string $subValue Is sub value?
*
* @return void * @return void
*/ */
public function setHeader($name, $value, $subValue = null) public function setHeader($name, $value, $subValue = null)
@ -57,6 +58,7 @@ abstract class PartHeader
* *
* @param string $name Header name * @param string $name Header name
* @param string $subValue Sub value name * @param string $subValue Sub value name
*
* @return mixed|array(mixed) * @return mixed|array(mixed)
*/ */
public function getHeader($name, $subValue = null) public function getHeader($name, $subValue = null)
@ -104,6 +106,7 @@ abstract class PartHeader
* Generates a header field value from the given value paramater. * Generates a header field value from the given value paramater.
* *
* @param array(string=>string)|string $value Header value * @param array(string=>string)|string $value Header value
*
* @return string * @return string
*/ */
protected function generateHeaderFieldValue($value) protected function generateHeaderFieldValue($value)
@ -129,6 +132,7 @@ abstract class PartHeader
* "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / <"> / "/" / "[" / "]" / "?" / "=" * "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / <"> / "/" / "[" / "]" / "?" / "="
* *
* @param string $string String to quote * @param string $string String to quote
*
* @return string * @return string
*/ */
private function quoteValueString($string) private function quoteValueString($string)

View File

@ -21,61 +21,68 @@ use BeSimple\SoapCommon\SoapResponseFilter;
/** /**
* SoapKernel provides methods to pre- and post-process SoapRequests and SoapResponses using * SoapKernel provides methods to pre- and post-process SoapRequests and SoapResponses using
* chains of SoapRequestFilter and SoapResponseFilter objects (roughly following * chains of SoapRequestFilter and SoapResponseFilter objects (roughly following
* the chain-of-responsibility pattern). * the chain-of-responsibility pattern).
* *
* @author Christian Kerl <christian-kerl@web.de> * @author Christian Kerl <christian-kerl@web.de>
*/ */
class SoapKernel class SoapKernel
{ {
private $requestFilters = array();
private $responseFilters = array();
/** /**
* Registers the given object either as filter for SoapRequests or as filter for SoapResponses * Request filters.
*
* @var array(SoapRequestFilter)
*/
private $requestFilters = array();
/**
* Response filters.
*
* @var array(SoapResponseFilter)
*/
private $responseFilters = array();
/**
* Registers the given object either as filter for SoapRequests or as filter for SoapResponses
* or as filter for both depending on the implemented interfaces. Inner filters have to be registered * or as filter for both depending on the implemented interfaces. Inner filters have to be registered
* before outer filters. This means the order is as follows: RequestFilter2->RequestFilter1 and * before outer filters. This means the order is as follows: RequestFilter2->RequestFilter1 and
* ResponseFilter1->ResponseFilter2. * ResponseFilter1->ResponseFilter2.
* *
* TODO: add priority mechanism to ensure correct order of filters * TODO: add priority mechanism to ensure correct order of filters
* *
* @param SoapRequestFilter|SoapResponseFilter $filter * @param SoapRequestFilter|SoapResponseFilter $filter Filter to register
*/ */
public function registerFilter($filter) public function registerFilter($filter)
{ {
if($filter instanceof SoapRequestFilter) if ($filter instanceof SoapRequestFilter) {
{
array_unshift($this->requestFilters, $filter); array_unshift($this->requestFilters, $filter);
} }
if($filter instanceof SoapResponseFilter) if ($filter instanceof SoapResponseFilter) {
{
array_push($this->responseFilters, $filter); array_push($this->responseFilters, $filter);
} }
} }
/** /**
* Applies all registered SoapRequestFilter to the given SoapRequest. * Applies all registered SoapRequestFilter to the given SoapRequest.
* *
* @param SoapRequest $request * @param SoapRequest $request Soap request
*/ */
public function filterRequest(SoapRequest $request) public function filterRequest(SoapRequest $request)
{ {
foreach($this->requestFilters as $filter) foreach ($this->requestFilters as $filter) {
{
$filter->filterRequest($request); $filter->filterRequest($request);
} }
} }
/** /**
* Applies all registered SoapResponseFilter to the given SoapResponse. * Applies all registered SoapResponseFilter to the given SoapResponse.
* *
* @param SoapResponse $response * @param SoapResponse $response SOAP response
*/ */
public function filterResponse(SoapResponse $response) public function filterResponse(SoapResponse $response)
{ {
foreach($this->responseFilters as $filter) foreach ($this->responseFilters as $filter) {
{
$filter->filterResponse($response); $filter->filterResponse($response);
} }
} }

View File

@ -91,6 +91,8 @@ abstract class SoapMessage
* Get content type for given SOAP version. * Get content type for given SOAP version.
* *
* @param string $version SOAP version constant SOAP_1_1|SOAP_1_2 * @param string $version SOAP version constant SOAP_1_1|SOAP_1_2
*
* @return string
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public static function getContentTypeForVersion($version) public static function getContentTypeForVersion($version)
@ -115,7 +117,7 @@ abstract class SoapMessage
/** /**
* Set SOAP action. * Set SOAP action.
* *
* @param string $action * @param string $action SOAP action
*/ */
public function setAction($action) public function setAction($action)
{ {
@ -138,7 +140,7 @@ abstract class SoapMessage
/** /**
* Set message content (MIME Message or SOAP Envelope). * Set message content (MIME Message or SOAP Envelope).
* *
* @param string $content * @param string $content SOAP message
*/ */
public function setContent($content) public function setContent($content)
{ {
@ -176,7 +178,7 @@ abstract class SoapMessage
/** /**
* Set content type. * Set content type.
* *
* @param string $contentType * @param string $contentType Content type header
*/ */
public function setContentType($contentType) public function setContentType($contentType)
{ {
@ -196,7 +198,7 @@ abstract class SoapMessage
/** /**
* Set location. * Set location.
* *
* @param string $location * @param string $location Location string
*/ */
public function setLocation($location) public function setLocation($location)
{ {
@ -216,7 +218,7 @@ abstract class SoapMessage
/** /**
* Set version. * Set version.
* *
* @param string $version * @param string $version SOAP version SOAP_1_1|SOAP_1_2
*/ */
public function setVersion($version) public function setVersion($version)
{ {

View File

@ -16,9 +16,11 @@ namespace BeSimple\SoapCommon;
use BeSimple\SoapCommon\SoapMessage; use BeSimple\SoapCommon\SoapMessage;
/** /**
* SOAP request message.
*
* @author Christian Kerl <christian-kerl@web.de> * @author Christian Kerl <christian-kerl@web.de>
*/ */
class SoapRequest extends SoapMessage class SoapRequest extends SoapMessage
{ {
} }

View File

@ -16,9 +16,16 @@ namespace BeSimple\SoapCommon;
use BeSimple\SoapCommon\SoapRequest; use BeSimple\SoapCommon\SoapRequest;
/** /**
* SOAP request filter interface.
*
* @author Christian Kerl <christian-kerl@web.de> * @author Christian Kerl <christian-kerl@web.de>
*/ */
interface SoapRequestFilter interface SoapRequestFilter
{ {
/**
* Modify SOAP response.
*
* @param SoapRequest $request SOAP request
*/
public function filterRequest(SoapRequest $request); public function filterRequest(SoapRequest $request);
} }

View File

@ -16,9 +16,11 @@ namespace BeSimple\SoapCommon;
use BeSimple\SoapCommon\SoapMessage; use BeSimple\SoapCommon\SoapMessage;
/** /**
* SOAP response message.
*
* @author Christian Kerl <christian-kerl@web.de> * @author Christian Kerl <christian-kerl@web.de>
*/ */
class SoapResponse extends SoapMessage class SoapResponse extends SoapMessage
{ {
} }

View File

@ -16,9 +16,16 @@ namespace BeSimple\SoapCommon;
use BeSimple\SoapCommon\SoapResponse; use BeSimple\SoapCommon\SoapResponse;
/** /**
* SOAP response filter interface.
*
* @author Christian Kerl <christian-kerl@web.de> * @author Christian Kerl <christian-kerl@web.de>
*/ */
interface SoapResponseFilter interface SoapResponseFilter
{ {
/**
* Modify SOAP response.
*
* @param SoapResponse $response SOAP response
*/
public function filterResponse(SoapResponse $response); public function filterResponse(SoapResponse $response);
} }

View File

@ -42,6 +42,7 @@ class WsSecurityKey
* @param string $key Private key * @param string $key Private key
* @param boolean $keyIsFile Given key parameter is path to key file * @param boolean $keyIsFile Given key parameter is path to key file
* @param string $passphrase Passphrase for key * @param string $passphrase Passphrase for key
*
* @return void * @return void
*/ */
public function addPrivateKey($encryptionType, $key = null, $keyIsFile = true, $passphrase = null) public function addPrivateKey($encryptionType, $key = null, $keyIsFile = true, $passphrase = null)
@ -55,6 +56,7 @@ class WsSecurityKey
* @param string $encryptionType Encryption type * @param string $encryptionType Encryption type
* @param string $key Public key * @param string $key Public key
* @param boolean $keyIsFile Given key parameter is path to key file * @param boolean $keyIsFile Given key parameter is path to key file
*
* @return void * @return void
*/ */
public function addPublicKey($encryptionType, $key = null, $keyIsFile = true) public function addPublicKey($encryptionType, $key = null, $keyIsFile = true)

View File

@ -87,6 +87,7 @@ class WsdlHandler
* Gets the mime type information from the WSDL file. * Gets the mime type information from the WSDL file.
* *
* @param string $soapAction Soap action to analyse * @param string $soapAction Soap action to analyse
*
* @return array(string=>array(string=>array(string))) * @return array(string=>array(string=>array(string)))
*/ */
private function getMimeTypesForSoapAction($soapAction) private function getMimeTypesForSoapAction($soapAction)
@ -152,6 +153,7 @@ class WsdlHandler
* @param string $operationType Operation type * @param string $operationType Operation type
* @param string $part Part name * @param string $part Part name
* @param string $currentMimeType Current mime type * @param string $currentMimeType Current mime type
*
* @return boolean * @return boolean
*/ */
public function isValidMimeTypeType($soapAction, $operationType, $part, $currentMimeType) public function isValidMimeTypeType($soapAction, $operationType, $part, $currentMimeType)