91 lines
2.8 KiB
PHP
91 lines
2.8 KiB
PHP
|
<?php
|
||
|
class WsWorldCheck
|
||
|
{
|
||
|
protected $webservices = array();
|
||
|
protected $cacheEnable = false;
|
||
|
protected $cacheWrite = false;
|
||
|
protected $headerData = array();
|
||
|
|
||
|
public function __construct()
|
||
|
{
|
||
|
$c = Zend_Registry::get('config');
|
||
|
$location = ($c->profil->webservice->location == 'production') ? 'production' : 'pilot';
|
||
|
$cWC = new Zend_Config_Ini('/Worldcheck/webservicesWC.ini', $location);
|
||
|
$config = $cWC->toArray();
|
||
|
$this->webservices = $config['webservices'];
|
||
|
|
||
|
$configWC = new Zend_Config_Ini('/Worldcheck/applicationWC.ini');
|
||
|
$data = $configWC->toArray();
|
||
|
$this->headerData = $data['worldcheck'];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* loadClientWC
|
||
|
* @param string $webservice
|
||
|
* @return SOAP client with Header
|
||
|
*/
|
||
|
protected function loadClientWC($webservice)
|
||
|
{
|
||
|
$wsdl = $this->webservices[$webservice]['wsdl'];
|
||
|
|
||
|
$options['soap_version'] = SOAP_1_1;
|
||
|
$options['features'] = SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS;
|
||
|
$options['compression'] = SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE;
|
||
|
$options['style'] = SOAP_DOCUMENT;
|
||
|
$options['use'] = SOAP_LITERAL;
|
||
|
$options['trace'] = true;
|
||
|
$options['encoding'] = 'utf-8';
|
||
|
|
||
|
$client = false;
|
||
|
|
||
|
$header = $this->headerWC();
|
||
|
|
||
|
try {
|
||
|
$client = new SoapClient($wsdl, $options);
|
||
|
$client->__setSoapHeaders($header);
|
||
|
} catch (Exception $e) {
|
||
|
throw new Exception('Application Error');
|
||
|
}
|
||
|
|
||
|
return $client;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Create security Header for WorldCheck
|
||
|
* @return SoapHeader
|
||
|
*/
|
||
|
protected function headerWC()
|
||
|
{
|
||
|
$headerPart = '<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">';
|
||
|
$headerPart .= '<wsse:UsernameToken wsu:Id="UsernameToken-19" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">';
|
||
|
$headerPart .= '<wsse:Username>'.$this->headerData['username'].'</wsse:Username>';
|
||
|
$headerPart .= '<wsse:Password Type="'.$this->headerData['passwordType'].'">'.$this->headerData['password'].'</wsse:Password>';
|
||
|
$headerPart .= '</wsse:UsernameToken></wsse:Security>';
|
||
|
|
||
|
$headerVar = new SoapVar($headerPart, XSD_ANYXML);
|
||
|
$header = new SoapHeader($this->headerData['namespace'], $this->headerData['securityType'], $headerVar, true);
|
||
|
return $header;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* getScreener
|
||
|
* @param object $data
|
||
|
* @return NameIdentifier
|
||
|
*/
|
||
|
public function getScreener($data)
|
||
|
{
|
||
|
$params = new stdClass();
|
||
|
$params->screenRequest = $data;
|
||
|
$client = $this->loadClientWC('screener');
|
||
|
try {
|
||
|
return $client->screen($params)->return;
|
||
|
} catch (SoapFault $fault) {
|
||
|
if ( in_array($fault->faultcode, array('ERR', 'MSG')) ){
|
||
|
return $fault->faultstring;
|
||
|
} else {
|
||
|
echo $client->__getLastResponse();
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|