working WS-Addressing and WS-Security filters

This commit is contained in:
Andreas Schamberger 2011-12-17 20:36:56 +01:00
parent 2e155db8f9
commit aa35e9e172
4 changed files with 50 additions and 12 deletions

View File

@ -191,13 +191,13 @@ class SoapClient extends \SoapClient
protected function __doRequest2(SoapRequest $soapRequest)
{
// run SoapKernel on SoapRequest
$soapRequest = $this->soapKernel->filterRequest($soapRequest);
$this->soapKernel->filterRequest($soapRequest);
// perform HTTP request with cURL
$soapResponse = $this->__doHttpRequest($soapRequest);
// run SoapKernel on SoapResponse
$soapResponse = $this->soapKernel->filterResponse($soapResponse);
$this->soapKernel->filterResponse($soapResponse);
return $soapResponse;
}

View File

@ -13,7 +13,9 @@
namespace BeSimple\SoapClient;
use BeSimple\SoapCommon\Helper;
use BeSimple\SoapCommon\SoapRequest as CommonSoapRequest;
use BeSimple\SoapCommon\SoapRequestFilter;
use BeSimple\SoapCommon\SoapResponse as CommonSoapResponse;
use BeSimple\SoapCommon\SoapResponseFilter;
/**
@ -161,6 +163,21 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
return null;
}
/**
* Reset all properties to default values.
*/
public function resetFilter()
{
$this->faultTo = null;
$this->from = null;
$this->messageId = null;
$this->referenceParametersRecieved = array();
$this->referenceParametersSet = array();
$this->relatesTo = null;
$this->relatesToRelationshipType = null;
$this->replyTo = null;
}
/**
* Set FaultTo address of type xs:anyURI.
*
@ -237,11 +254,11 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Modify the given request XML.
*
* @param SoapRequest $request SOAP request
* @param \BeSimple\SoapCommon\SoapRequest $request SOAP request
*
* @return void
*/
public function filterRequest(SoapRequest $request)
public function filterRequest(CommonSoapRequest $request)
{
// get \DOMDocument from SOAP request
$dom = $request->getContentDocument();
@ -306,11 +323,11 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Modify the given response XML.
*
* @param SoapResponse $response SOAP response
* @param \BeSimple\SoapCommon\SoapResponse $response SOAP response
*
* @return void
*/
public function filterResponse(SoapResponse $response)
public function filterResponse(CommonSoapResponse $response)
{
// get \DOMDocument from SOAP response
$dom = $response->getContentDocument();

View File

@ -17,7 +17,9 @@ use ass\XmlSecurity\Enc as XmlSecurityEnc;
use ass\XmlSecurity\Key as XmlSecurityKey;
use BeSimple\SoapCommon\Helper;
use BeSimple\SoapCommon\SoapRequest as CommonSoapRequest;
use BeSimple\SoapCommon\SoapRequestFilter;
use BeSimple\SoapCommon\SoapResponse as CommonSoapResponse;
use BeSimple\SoapCommon\SoapResponseFilter;
use BeSimple\SoapCommon\WsSecurityKey;
@ -178,6 +180,25 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
$this->passwordType = $passwordType;
}
/**
* Reset all properties to default values.
*/
public function resetFilter()
{
$this->actor = null;
$this->addTimestamp = null;
$this->encryptSignature = null;
$this->expires = null;
$this->password = null;
$this->passwordType = null;
$this->serviceSecurityKey = null;
$this->signAllHeaders = null;
$this->tokenReferenceEncryption = null;
$this->tokenReferenceSignature = null;
$this->username = null;
$this->userSecurityKey = null;
}
/**
* Get service security key.
*
@ -233,11 +254,11 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Modify the given request XML.
*
* @param SoapRequest $request SOAP request to modify
* @param \BeSimple\SoapCommon\SoapRequest $request SOAP request
*
* @return void
*/
public function filterRequest(SoapRequest $request)
public function filterRequest(CommonSoapRequest $request)
{
// get \DOMDocument from SOAP request
$dom = $request->getContentDocument();
@ -256,7 +277,7 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
// create security header
$security = $filterHelper->createElement(Helper::NS_WSS, 'Security');
$filterHelper->addHeaderElement($security, true, $this->actor, $request->getSoapVersion());
$filterHelper->addHeaderElement($security, true, $this->actor, $request->getVersion());
if (true === $this->addTimestamp || null !== $this->expires) {
$timestamp = $filterHelper->createElement(Helper::NS_WSU, 'Timestamp');
@ -355,11 +376,11 @@ class WsSecurityFilter implements SoapRequestFilter, SoapResponseFilter
/**
* Modify the given request XML.
*
* @param SoapResponse $response SOAP response to modify
* @param \BeSimple\SoapCommon\SoapResponse $response SOAP response
*
* @return void
*/
public function filterResponse(SoapResponse $response)
public function filterResponse(CommonSoapResponse $response)
{
// get \DOMDocument from SOAP response
$dom = $response->getContentDocument();