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

View File

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

View File

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

View File

@ -68,6 +68,7 @@ class Part extends PartHeader
* @param string $charset Charset
* @param string $encoding Encoding
* @param string $contentId Content id
*
* @return void
*/
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);
if (!is_null($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-Transfer-Encoding', $encoding);
@ -110,6 +111,7 @@ class Part extends PartHeader
* Set mime content.
*
* @param mixed $content Content to set
*
* @return void
*/
public function setContent($content)

View File

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

View File

@ -28,7 +28,18 @@ use BeSimple\SoapCommon\SoapResponseFilter;
*/
class SoapKernel
{
/**
* Request filters.
*
* @var array(SoapRequestFilter)
*/
private $requestFilters = array();
/**
* Response filters.
*
* @var array(SoapResponseFilter)
*/
private $responseFilters = array();
/**
@ -39,17 +50,15 @@ class SoapKernel
*
* 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)
{
if($filter instanceof SoapRequestFilter)
{
if ($filter instanceof SoapRequestFilter) {
array_unshift($this->requestFilters, $filter);
}
if($filter instanceof SoapResponseFilter)
{
if ($filter instanceof SoapResponseFilter) {
array_push($this->responseFilters, $filter);
}
}
@ -57,12 +66,11 @@ class SoapKernel
/**
* Applies all registered SoapRequestFilter to the given SoapRequest.
*
* @param SoapRequest $request
* @param SoapRequest $request Soap request
*/
public function filterRequest(SoapRequest $request)
{
foreach($this->requestFilters as $filter)
{
foreach ($this->requestFilters as $filter) {
$filter->filterRequest($request);
}
}
@ -70,12 +78,11 @@ class SoapKernel
/**
* Applies all registered SoapResponseFilter to the given SoapResponse.
*
* @param SoapResponse $response
* @param SoapResponse $response SOAP response
*/
public function filterResponse(SoapResponse $response)
{
foreach($this->responseFilters as $filter)
{
foreach ($this->responseFilters as $filter) {
$filter->filterResponse($response);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -42,6 +42,7 @@ class WsSecurityKey
* @param string $key Private key
* @param boolean $keyIsFile Given key parameter is path to key file
* @param string $passphrase Passphrase for key
*
* @return void
*/
public function addPrivateKey($encryptionType, $key = null, $keyIsFile = true, $passphrase = null)
@ -55,6 +56,7 @@ class WsSecurityKey
* @param string $encryptionType Encryption type
* @param string $key Public key
* @param boolean $keyIsFile Given key parameter is path to key file
*
* @return void
*/
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.
*
* @param string $soapAction Soap action to analyse
*
* @return array(string=>array(string=>array(string)))
*/
private function getMimeTypesForSoapAction($soapAction)
@ -152,6 +153,7 @@ class WsdlHandler
* @param string $operationType Operation type
* @param string $part Part name
* @param string $currentMimeType Current mime type
*
* @return boolean
*/
public function isValidMimeTypeType($soapAction, $operationType, $part, $currentMimeType)