This commit is contained in:
Andreas Schamberger 2011-12-17 16:05:25 +01:00
parent 8a886c7eda
commit 2e155db8f9
8 changed files with 140 additions and 103 deletions

View File

@ -50,8 +50,8 @@ class Curl
/**
* Constructor.
*
* @param array $options
* @param int $followLocationMaxRedirects
* @param array $options Options array from SoapClient constructor
* @param int $followLocationMaxRedirects Redirection limit for Location header
*/
public function __construct(array $options = array(), $followLocationMaxRedirects = 10)
{
@ -109,9 +109,10 @@ class Curl
* Execute HTTP request.
* Returns true if request was successfull.
*
* @param string $location
* @param string $request
* @param array $requestHeaders
* @param string $location HTTP location
* @param string $request Request body
* @param array $requestHeaders Request header strings
*
* @return bool
*/
public function exec($location, $request = null, $requestHeaders = array())
@ -136,9 +137,8 @@ class Curl
* Custom curl_exec wrapper that allows to follow redirects when specific
* http response code is set. SOAP only allows 307.
*
* @param resource $ch
* @param int $maxRedirects
* @param int $redirects
* @param int $redirects Current redirection count
*
* @return mixed
*/
private function execManualRedirect($redirects = 0)
@ -186,7 +186,7 @@ class Curl
*
* http://curl.haxx.se/libcurl/c/libcurl-errors.html
*
* @var array(int=>string)
* @return array(int=>string)
*/
protected function getErrorCodeMapping()
{

View File

@ -36,7 +36,7 @@ class FilterHelper
/**
* Constructor.
*
* @param \DOMDocument $domDocument
* @param \DOMDocument $domDocument SOAP document
*/
public function __construct(\DOMDocument $domDocument)
{
@ -46,10 +46,11 @@ class FilterHelper
/**
* Add new soap header.
*
* @param \DOMElement $node
* @param boolean $mustUnderstand
* @param string $actor
* @param string $soapVersion
* @param \DOMElement $node DOMElement to add
* @param boolean $mustUnderstand SOAP header mustUnderstand attribute
* @param string $actor SOAP actor/role
* @param string $soapVersion SOAP version SOAP_1_1|SOAP_1_2
*
* @return void
*/
public function addHeaderElement(\DOMElement $node, $mustUnderstand = null, $actor = null, $soapVersion = SOAP_1_1)
@ -86,7 +87,8 @@ class FilterHelper
/**
* Add new soap body element.
*
* @param \DOMElement $node
* @param \DOMElement $node DOMElement to add
*
* @return void
*/
public function addBodyElement(\DOMElement $node)
@ -109,8 +111,9 @@ class FilterHelper
/**
* Add new namespace to root tag.
*
* @param string $prefix
* @param string $namespaceURI
* @param string $prefix Namespace prefix
* @param string $namespaceURI Namespace URI
*
* @return void
*/
public function addNamespace($prefix, $namespaceURI)
@ -125,9 +128,10 @@ class FilterHelper
/**
* Create new element for given namespace.
*
* @param string $namespaceURI
* @param string $name
* @param string $value
* @param string $namespaceURI Namespace URI
* @param string $name Element name
* @param string $value Element value
*
* @return \DOMElement
*/
public function createElement($namespaceURI, $name, $value = null)
@ -140,13 +144,14 @@ class FilterHelper
/**
* Add new attribute to element with given namespace.
*
* @param \DOMElement $element
* @param string $namespaceURI
* @param string $name
* @param string $value
* @param \DOMElement $element DOMElement to edit
* @param string $namespaceURI Namespace URI
* @param string $name Attribute name
* @param string $value Attribute value
*
* @return void
*/
public function setAttribute(\DOMElement $element, $namespaceURI = null, $name, $value)
public function setAttribute(\DOMElement $element, $namespaceURI, $name, $value)
{
if (null !== $namespaceURI) {
$prefix = $this->namespaces[$namespaceURI];
@ -159,8 +164,9 @@ class FilterHelper
/**
* Register namespace.
*
* @param string $prefix
* @param string $namespaceURI
* @param string $prefix Namespace prefix
* @param string $namespaceURI Namespace URI
*
* @return void
*/
public function registerNamespace($prefix, $namespaceURI)

View File

@ -113,7 +113,8 @@ class SoapClient extends \SoapClient
/**
* Perform HTTP request with cURL.
*
* @param SoapRequest $soapRequest
* @param SoapRequest $soapRequest SoapRequest object
*
* @return SoapResponse
*/
private function __doHttpRequest(SoapRequest $soapRequest)
@ -144,11 +145,13 @@ class SoapClient extends \SoapClient
$this->lastResponse = $this->curl->getResponseBody();
}
// wrap response data in SoapResponse object
$soapResponse = SoapResponse::create($this->curl->getResponseBody(),
$soapResponse = SoapResponse::create(
$this->curl->getResponseBody(),
$soapRequest->getLocation(),
$soapRequest->getAction(),
$soapRequest->getVersion(),
$this->curl->getResponseContentType());
$this->curl->getResponseContentType()
);
return $soapResponse;
}
@ -157,11 +160,12 @@ class SoapClient extends \SoapClient
* Custom request method to be able to modify the SOAP messages.
* $oneWay parameter is not used at the moment.
*
* @param string $request
* @param string $location
* @param string $action
* @param int $version
* @param string $request Request string
* @param string $location Location
* @param string $action SOAP action
* @param int $version SOAP version
* @param int $oneWay 0|1
*
* @return string
*/
public function __doRequest($request, $location, $action, $version, $oneWay = 0)
@ -180,7 +184,8 @@ class SoapClient extends \SoapClient
* Runs the currently registered request filters on the request, performs
* the HTTP request and runs the response filters.
*
* @param SoapRequest $soapRequest
* @param SoapRequest $soapRequest SOAP request object
*
* @return SoapResponse
*/
protected function __doRequest2(SoapRequest $soapRequest)
@ -287,6 +292,7 @@ class SoapClient extends \SoapClient
*
* @param string $wsdl WSDL file
* @param array(string=>mixed) $options Options array
*
* @return string
*/
private function loadWsdl($wsdl, array $options)

View File

@ -25,10 +25,11 @@ class SoapRequest extends CommonSoapRequest
/**
* Factory function for SoapRequest.
*
* @param string $content
* @param string $location
* @param string $action
* @param string $version
* @param string $content Content
* @param string $location Location
* @param string $action SOAP action
* @param string $version SOAP version
*
* @return BeSimple\SoapClient\SoapRequest
*/
public static function create($content, $location, $action, $version)

View File

@ -25,11 +25,12 @@ class SoapResponse extends CommonSoapResponse
/**
* Factory function for SoapResponse.
*
* @param string $content
* @param string $location
* @param string $action
* @param string $version
* @param string $contentType
* @param string $content Content
* @param string $location Location
* @param string $action SOAP action
* @param string $version SOAP version
* @param string $contentType Content type header
*
* @return BeSimple\SoapClient\SoapResponse
*/
public static function create($content, $location, $action, $version, $contentType)

View File

@ -126,10 +126,11 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Add additional reference parameters
*
* @param string $ns
* @param string $pfx
* @param string $parameter
* @param string $value
* @param string $ns Namespace URI
* @param string $pfx Namespace prefix
* @param string $parameter Parameter name
* @param string $value Parameter value
*
* @return void
*/
public function addReferenceParameter($ns, $pfx, $parameter, $value)
@ -145,8 +146,9 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Get additional reference parameters.
*
* @param string $ns
* @param string $parameter
* @param string $ns Namespace URI
* @param string $parameter Parameter name
*
* @return string|null
*/
public function getReferenceParameter($ns, $parameter)
@ -162,7 +164,8 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Set FaultTo address of type xs:anyURI.
*
* @param string $action
* @param string $faultTo xs:anyURI
*
* @return void
*/
public function setFaultTo($faultTo)
@ -173,7 +176,8 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Set From address of type xs:anyURI.
*
* @param string $action
* @param string $from xs:anyURI
*
* @return void
*/
public function setFrom($from)
@ -185,7 +189,8 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
* Set MessageId of type xs:anyURI.
* Default: UUID v4 e.g. 'uuid:550e8400-e29b-11d4-a716-446655440000'
*
* @param string $messageId
* @param string $messageId xs:anyURI
*
* @return void
*/
public function setMessageId($messageId = null)
@ -200,8 +205,9 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
* Set RelatesTo of type xs:anyURI with the optional relationType
* (of type xs:anyURI).
*
* @param string $relatesTo
* @param string $relationType
* @param string $relatesTo xs:anyURI
* @param string $relationType xs:anyURI
*
* @return void
*/
public function setRelatesTo($relatesTo, $relationType = null)
@ -216,7 +222,8 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
* Set ReplyTo address of type xs:anyURI
* Default: self::ENDPOINT_REFERENCE_ANONYMOUS
*
* @param string $replyTo
* @param string $replyTo xs:anyURI
*
* @return void
*/
public function setReplyTo($replyTo = null)
@ -230,7 +237,8 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Modify the given request XML.
*
* @param SoapRequest $dom
* @param SoapRequest $request SOAP request
*
* @return void
*/
public function filterRequest(SoapRequest $request)
@ -298,7 +306,8 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Modify the given response XML.
*
* @param SoapResponse $response
* @param SoapResponse $response SOAP response
*
* @return void
*/
public function filterResponse(SoapResponse $response)

View File

@ -153,7 +153,7 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
*
* @param boolean $addTimestamp (SMS 10) Add security timestamp.
* @param int $expires (SMS 10) Security timestamp expires time in seconds.
* @param string $actor
* @param string $actor SOAP actor
*/
public function __construct($addTimestamp = true, $expires = 300, $actor = null)
{
@ -165,9 +165,10 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Add user data.
*
* @param string $username
* @param string $password
* @param string $username Username
* @param string $password Password
* @param int $passwordType self::PASSWORD_TYPE_DIGEST | self::PASSWORD_TYPE_TEXT
*
* @return void
*/
public function addUserData($username, $password = null, $passwordType = self::PASSWORD_TYPE_DIGEST)
@ -180,7 +181,8 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Get service security key.
*
* @param \BeSimple\SoapCommon\WsSecurityKey $serviceSecurityKey
* @param \BeSimple\SoapCommon\WsSecurityKey $serviceSecurityKey Service security key
*
* @return void
*/
public function setServiceSecurityKeyObject(WsSecurityKey $serviceSecurityKey)
@ -191,7 +193,8 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Get user security key.
*
* @param \BeSimple\SoapCommon\WsSecurityKey $userSecurityKey
* @param \BeSimple\SoapCommon\WsSecurityKey $userSecurityKey User security key
*
* @return void
*/
public function setUserSecurityKeyObject(WsSecurityKey $userSecurityKey)
@ -203,7 +206,8 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
* Set security options.
*
* @param int $tokenReference self::TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | self::TOKEN_REFERENCE_SECURITY_TOKEN | self::TOKEN_REFERENCE_THUMBPRINT_SHA1
* @param boolean $encryptSignature
* @param boolean $encryptSignature Encrypt signature
*
* @return void
*/
public function setSecurityOptionsEncryption($tokenReference, $encryptSignature = false)
@ -216,7 +220,8 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
* Set security options.
*
* @param int $tokenReference self::TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | self::TOKEN_REFERENCE_SECURITY_TOKEN | self::TOKEN_REFERENCE_THUMBPRINT_SHA1
* @param boolean $signAllHeaders
* @param boolean $signAllHeaders Sign all headers?
*
* @return void
*/
public function setSecurityOptionsSignature($tokenReference, $signAllHeaders = false)
@ -228,7 +233,8 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Modify the given request XML.
*
* @param SoapRequest $dom
* @param SoapRequest $request SOAP request to modify
*
* @return void
*/
public function filterRequest(SoapRequest $request)
@ -349,7 +355,8 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Modify the given request XML.
*
* @param SoapResponse $response
* @param SoapResponse $response SOAP response to modify
*
* @return void
*/
public function filterResponse(SoapResponse $response)
@ -397,12 +404,11 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Adds the configured KeyInfo to the parentNode.
*
* @param FilterHelper $filterHelper
* @param int $tokenReference
* @param \DOMNode $parentNode
* @param string $guid
* @param \ass\XmlSecurity\Key $xmlSecurityKey
* @param \DOMNode $insertBefore
* @param FilterHelper $filterHelper Filter helper object
* @param int $tokenReference Token reference type
* @param string $guid Unique ID
* @param \ass\XmlSecurity\Key $xmlSecurityKey XML security key
*
* @return \DOMElement
*/
protected function createKeyInfo(FilterHelper $filterHelper, $tokenReference, $guid, XmlSecurityKey $xmlSecurityKey = null)
@ -444,8 +450,9 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Create a list of \DOMNodes that should be encrypted.
*
* @param \DOMDocument $dom
* @param \DOMElement $security
* @param \DOMDocument $dom DOMDocument to query
* @param \DOMElement $security Security element
*
* @return \DOMNodeList
*/
protected function createNodeListForEncryption(\DOMDocument $dom, \DOMElement $security)
@ -465,8 +472,9 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Create a list of \DOMNodes that should be signed.
*
* @param \DOMDocument $dom
* @param \DOMElement $security
* @param \DOMDocument $dom DOMDocument to query
* @param \DOMElement $security Security element
*
* @return array(\DOMNode)
*/
protected function createNodeListForSigning(\DOMDocument $dom, \DOMElement $security)
@ -496,8 +504,9 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Gets the referenced node for the given URI.
*
* @param \DOMElement $node
* @param string $uri
* @param \DOMElement $node Node
* @param string $uri URI
*
* @return \DOMElement
*/
protected function getReferenceNodeForUri(\DOMElement $node, $uri)
@ -514,8 +523,9 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Tries to resolve a key from the given \DOMElement.
*
* @param \DOMElement $node
* @param string $algorithm
* @param \DOMElement $node Node where to resolve the key
* @param string $algorithm XML security key algorithm
*
* @return \ass\XmlSecurity\Key|null
*/
public function keyInfoSecurityTokenReferenceResolver(\DOMElement $node, $algorithm)

View File

@ -87,7 +87,8 @@ class WsdlDownloader
/**
* Download given WSDL file and return name of cache file.
*
* @param string $wsdl
* @param string $wsdl WSDL file URL/path
*
* @return string
*/
public function download($wsdl)
@ -134,7 +135,8 @@ class WsdlDownloader
/**
* Do we have a remote file?
*
* @param string $file
* @param string $file File URL/path
*
* @return boolean
*/
private function isRemoteFile($file)
@ -153,9 +155,10 @@ class WsdlDownloader
/**
* Resolves remote WSDL/XSD includes within the WSDL files.
*
* @param string $xml
* @param string $cacheFile
* @param unknown_type $parentIsRemote
* @param string $xml XML file
* @param string $cacheFile Cache file name
* @param boolean $parentFile Parent file name
*
* @return void
*/
private function resolveRemoteIncludes($xml, $cacheFile, $parentFile = null)
@ -203,8 +206,9 @@ class WsdlDownloader
/**
* Resolves the relative path to base into an absolute.
*
* @param string $base
* @param string $relative
* @param string $base Base path
* @param string $relative Relative path
*
* @return string
*/
private function resolveRelativePathInUrl($base, $relative)