profil->webservice->location == 'production') ? 'production' : 'pilot'; $cWC = new Zend_Config_Ini(APPLICATION_PATH . '/../library/WorldCheck/webservicesWC.ini', $location); $config = $cWC->toArray(); $this->webservices = $config['webservices']; $configWC = new Zend_Config_Ini(APPLICATION_PATH . '/../library/WorldCheck/applicationWC.ini'); $data = $configWC->toArray(); $this->wcData = $data['wsworldcheck']; } /** * 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'; if (APPLICATION_ENV == 'development'){ $options['cache_wsdl'] = WSDL_CACHE_NONE; } $client = false; $header = $this->headerWC(); try { $client = new SoapClient(realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . $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 = ''; $headerPart .= ''; $headerPart .= ''.$this->wcData['username'].''; $headerPart .= ''.$this->wcData['password'].''; $headerPart .= ''; $headerVar = new SoapVar($headerPart, XSD_ANYXML); $header = new SoapHeader($this->wcData['namespace'], $this->wcData['securityType'], $headerVar, true); return $header; } //**** SCREENER WSDL ****// /** * The initial request of Worldcheck to get nameIdentifier. * nameType available values: 'INDIVIDUAL', 'ORGANISATION' * @param object $data * @return nameIdentifier (Unique for each request, begins with so_n_) */ public function getScreener($data) { $params = new stdClass(); $params->screenRequest = $data; $params->screenRequest->groupIdentifier = $this->wcData['groupIdentifier']; $params->screenRequest->assigneeIdentifier = $this->wcData['assigneeIdentifier']; $params->screenRequest->customId1 = '1'; $params->screenRequest->customId2 = '2'; $client = $this->loadClientWC('screener'); try { $response = $client->screen($params); //echo $client->__getLastRequest(); //echo $client->__getLastResponse(); return $response->return; } catch (SoapFault $fault) { if ($fault->faultcode){ echo $fault->faultstring; return false; } else { echo $client->__getLastResponse(); return false; } } } //**** CONTENT WSDL ****// /** * getContentSources * @return Content Sources */ public function getContentSources() { $client = $this->loadClientWC('content'); try { return $client->getContentSources()->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getDetails * @param object: matchIdentifier, nameType * @return object content */ public function getDetailsContent($params) { $client = $this->loadClientWC('content'); $param = new stdClass(); $nameType = strtolower($params->nameType); $param->matchIdentifier = $params->matchIdentifier; try { return $client->getDetails($param)->return->entitySet->entities->$nameType; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * get branch of associates - tree * @param object: matchIdentifier, nameType * @return object content */ public function getBranchTree($params) { $client = $this->loadClientWC('content'); $param = new stdClass(); $nameType = strtolower($params->nameType); $param->matchIdentifier = $params->matchIdentifier; try { return $client->getDetails($param)->return->entitySet->entities->$nameType; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getAssociates * @param object: matchIdentifier, nameType * @return array */ public function getAssociates($params) { $client = $this->loadClientWC('content'); $param = new stdClass(); $nameType = strtolower($params->nameType); $param->matchIdentifier = $params->matchIdentifier; $primary = array(); $associates = array(); try { $response = $client->getDetails($param)->return->entitySet->entities; if ($nameType=='individual') { $prim = $response->individual[0]; } else { $prim = $response->organisation[0]; } $primary['entityId'] = $prim->entityId; $primary['nameType'] = strtoupper($nameType); $primary['category'] = $prim->category; $primary['fullName'] = $prim->names->name[0]->fullName; $primary['givenName'] = $prim->names->name[0]->givenName; $primary['lastName'] = $prim->names->name[0]->lastName; $primary['biography'] = $prim->details->detail[0]->text; $primary['identification'] = $prim->details->detail[1]->text; $assoc = $prim->associates; foreach ($assoc->associate as $associate) { $assoc = array(); $assoc['entityId'] = $associate->targetEntity->entityId; $assoc['nameType'] = ($associate->associatetype=='ASSOCIATE')?'INDIVIDUAL':'ORGANISATION'; $assoc['category'] = $associate->targetEntity->category; $assoc['fullName'] = $associate->targetEntity->names->name[0]->fullName; $assoc['givenName'] = $associate->targetEntity->names->name[0]->givenName; $assoc['lastName'] = $associate->targetEntity->names->name[0]->lastName; $assoc['biography'] = $associate->targetEntity->details->detail[0]->text; $assoc['identification'] = $associate->targetEntity->details->detail[1]->text; $associates[] = $assoc; } $output = array('primary' => $primary, 'associates' => $associates); return $output; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getSummaries * @param object * @return object content */ public function getSummaries($data) { $client = $this->loadClientWC('content'); $param = new stdClass(); $param->nameIdentifier = $data->nameIdentifier; $param->matchType = $data->matchType; // value must be watchlist $param->start = $this->wcData['response']['start']; $param->limit = $this->wcData['response']['limit']; try { return $client->getSummaries($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * return an array, where key=entityId, and value=fullName according to nameIdentifier * @param object * @return array */ public function getSummariesArr($data) { $allMatches = array(); $client = $this->loadClientWC('content'); $param = new stdClass(); $param->nameIdentifier = $data->nameIdentifier; $param->matchType = $data->matchType; // value must be watchlist $param->start = $this->wcData['response']['start']; $param->limit = $this->wcData['response']['limit']; try { $category = $client->getSummaries($param)->return->entitySummaries->categories; foreach ($category->category as $category) { foreach($category->summaries->summary as $summary) { $key = $summary->entityId->entityId; $shortData = new stdClass(); $shortData->fullName = $summary->names->name[0]->fullName; $shortData->givenName = $summary->names->name[0]->givenName; $shortData->lastName = $summary->names->name[0]->lastName; $shortData->description = $summary->groups->group[0]->details->detail[0]->description; if (isset($summary->countryLinks->countryLink)){ $shortData->country = $summary->countryLinks->countryLink[0]->countryText; } $allMatches[$key] = $shortData; } } return $allMatches; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getSummariesForMatch * @param string matchIdentifier * @return object content */ public function getSummariesForMatch($matchIdentifier) { $client = $this->loadClientWC('content'); $param = new stdClass(); $param->matchIdentifier = $matchIdentifier; try { return $client->getSummariesForMatch($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * return object with entityId and fullName according to matchIdentifier * @param string matchIdentifier * @return object */ public function getSummariesForMatchEntityId($matchIdentifier) { $data = new stdClass(); $client = $this->loadClientWC('content'); $param = new stdClass(); $param->matchIdentifier = $matchIdentifier; try { $data->entityId = $client->getSummariesForMatch($param)->return->entitySummaries->categories->category[0]->summaries->summary[0]->entityId->entityId; $data->fullName = $client->getSummariesForMatch($param)->return->entitySummaries->categories->category[0]->summaries->summary[0]->names->name[0]->fullName; return $data; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getTitles * @param object * @return object content */ public function getTitles($data) { $client = $this->loadClientWC('content'); $param = new stdClass(); $param->matchIdentifier = $data->matchIdentifier; $param->matchType = $data->matchType; // value must be watchlist $param->start = $this->wcData['response']['start']; $param->limit = $this->wcData['response']['limit']; try { return $client->getTitles($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getTitlesForMatch * @param string matchIdentifier * @return object content */ public function getTitlesForMatch($matchIdentifier) { $client = $this->loadClientWC('content'); $param = new stdClass(); $param->matchIdentifier = $matchIdentifier; $usefulData = new stdClass(); try { $output = $client->getTitlesForMatch($param)->return->contentTitles->contentTitle[0]; $usefulData->entityId = $output->entityId; $usefulData->lastName = $output->names->name[0]->lastName; $usefulData->givenName = $output->names->name[0]->givenName; return $usefulData; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } //**** USER WSDL ****// /** * change My Password * @param string new password * @return boolean */ public function changeMyPassword($newPassword) { $client = $this->loadClientWC('user'); $param = new stdClass(); $param->newPassword = $newPassword; try { return $client->changeMyPassword($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * reset Password * @param string username * @return new password */ public function resetPassword($username) { $client = $this->loadClientWC('user'); $param = new stdClass(); $param->username = $username; try { return $client->resetPassword($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * get Usernames * @param string userIdentifier * @return object userNames */ public function getUserNames($userIdentifier) { $client = $this->loadClientWC('user'); $param = new stdClass(); $param->userIdentifierList->userIdentifiers->userIdentifier = $userIdentifier; try { return $client->getUserNames($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } //**** PREFERENCE WSDL ****// /** * getAllGroupConfingVariables * @param string groupIdentifier * @return object preference */ public function getAllGroupConfingVariables($groupIdentifier) { $client = $this->loadClientWC('preference'); $param = new stdClass(); $param->groupIdentifier = $groupIdentifier; try { return $client->getAllGroupConfingVariables($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getGroupConfigVariable * @param string groupIdentifier * @return object preferenceValues */ public function getGroupConfigVariable($groupIdentifier, $groupConfigVariableType) { $client = $this->loadClientWC('preference'); $param = new stdClass(); $param->groupIdentifier = $groupIdentifier; $param->groupConfigVariableType = $groupConfigVariableType; try { return $client->getGroupConfigVariable($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getGroupConfigVariables * @param string groupIdentifier * @param string groupConfigVariableType * @return object preferenceValues */ public function getGroupConfigVariables($groupIdentifier, $groupConfigVariableType) { $client = $this->loadClientWC('preference'); $param = new stdClass(); $param->groupIdentifier = $groupIdentifier; $param->groupConfigVariableTypeSet->groupConfigVariableTypes->groupConfigVariableType = $groupConfigVariableType; try { return $client->getGroupConfigVariables($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } //**** STOREDNAME WSDL ****// /** * getStoredNameModel * @param string groupIdentifier * @return object */ public function getStoredNameModel($groupIdentifier) { $client = $this->loadClientWC('storedName'); $param = new stdClass(); $param->groupIdentifier = $groupIdentifier; try { return $client->getStoredNameModel($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getStoredNameModelForAllGroups * @return object */ public function getStoredNameModelForAllGroups() { $client = $this->loadClientWC('storedName'); try { return $client->getStoredNameModelForAllGroups()->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getStoredNameModelGroups * @return object */ public function getStoredNameModelGroups() { $client = $this->loadClientWC('storedName'); try { return $client->getStoredNameModelGroups()->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getUserFilters * @return object */ public function getUserFilters() { $client = $this->loadClientWC('storedName'); try { return $client->getUserFilters()->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } //**** NAME WSDL ****// /** * addNote * @param string nameIdentifier * @param string note * @return string [success] */ public function addNoteName($nameIdentifier, $note) { $client = $this->loadClientWC('name'); $param = new stdClass(); $param->nameIdentifierList->nameIdentifiers->nameIdentifier = $nameIdentifier; $param->note = $note; try { return $client->addNote($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * archive * @param string nameIdentifier * @return string [success] */ public function archive($nameIdentifier) { $client = $this->loadClientWC('name'); $param = new stdClass(); $param->nameIdentifierList->nameIdentifiers->nameIdentifier = $nameIdentifier; try { return $client->archive($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * delete * @param string nameIdentifier * @return string [success] */ public function delete($nameIdentifier) { $client = $this->loadClientWC('name'); $param = new stdClass(); $param->nameIdentifierList->nameIdentifiers->nameIdentifier = $nameIdentifier; try { return $client->delete($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * assign * @param string nameIdentifier * @param string assigneeIdentifier * @return string [success] */ public function assign($nameIdentifier, $assigneeIdentifier) { $client = $this->loadClientWC('name'); $param = new stdClass(); $param->nameIdentifierList->nameIdentifiers->nameIdentifier = $nameIdentifier; $param->assigneeIdentifier = $assigneeIdentifier; try { return $client->assign($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * unassign * @param string nameIdentifier * @return string [success] */ public function unassign($nameIdentifier) { $client = $this->loadClientWC('name'); $param = new stdClass(); $param->nameIdentifierList->nameIdentifiers->nameIdentifier = $nameIdentifier; try { return $client->unassign($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * changeOwner * @param string nameIdentifier * @param string ownerIdentifier * @return object */ public function changeOwner($nameIdentifier, $ownerIdentifier) { $client = $this->loadClientWC('name'); $param = new stdClass(); $param->nameIdentifierList->nameIdentifiers->nameIdentifier = $nameIdentifier; $param->ownerIdentifier = $ownerIdentifier; try { return $client->changeOwner($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getDetailsName * @param string nameIdentifier * @return object */ public function getDetailsName($nameIdentifier) { $client = $this->loadClientWC('name'); $param = new stdClass(); $param->nameIdentifier = $nameIdentifier; try { return $client->getDetails($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getMatches * @param string nameIdentifier * @param string matchType * @return object */ public function getMatchesName($nameIdentifier, $matchType) { $client = $this->loadClientWC('name'); $param = new stdClass(); $param->nameIdentifier = $nameIdentifier; $param->matchType = $matchType; $param->start = $this->wcData['response']['start']; $param->limit = $this->wcData['response']['limit']; try { return $client->getMatches($param)->return->matches; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * Returns array where key=entityId, and value=matchIdentifier according to nameIdentifier * @param object data (contains nameIdentifier, matchType) * @return array */ public function getMatchesArrName($data) { $allMatches = array(); $client = $this->loadClientWC('name'); $param = new stdClass(); $param->nameIdentifier = $data->nameIdentifier; $param->matchType = $data->matchType; // value must be watchlist $param->start = $this->wcData['response']['start']; $param->limit = $this->wcData['response']['limit']; try { $matches = $client->getMatches($param)->return->matches; foreach ($matches->match as $matchData) { $allMatches[$matchData->matchEntityIdentifier] = $matchData->matchIdentifier; } return $allMatches; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getSelectableAssignees * @param string groupIdentifier * @return object */ public function getSelectableAssignees($groupIdentifier) { $client = $this->loadClientWC('name'); $param = new stdClass(); $param->groupIdentifier = $groupIdentifier; try { return $client->getSelectableAssignees($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getSelectableGroups * @return object */ public function getSelectableGroups() { $client = $this->loadClientWC('name'); try { return $client->getSelectableGroups()->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getSelectableOwners * @return object */ public function getSelectableOwners($groupIdentifier, $nameSystemStatus) { $client = $this->loadClientWC('name'); $param = new stdClass(); $param->groupIdentifier = $groupIdentifier; $param->nameSystemStatus = $nameSystemStatus; try { return $client->getSelectableOwners($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * saveForOngoingScreening * @param string nameIdentifier * @param string ownerIdentifier * @return object */ public function saveForOngoingScreening($nameIdentifier) { $client = $this->loadClientWC('name'); $param = new stdClass(); $param->nameIdentifierList->nameIdentifiers->nameIdentifier = $nameIdentifier; try { return $client->saveForOngoingScreening($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } //**** MATCH WSDL ****// /** * acknoledge * @param string matchIdentifier * @param string note * @return object */ public function acknoledge($matchIdentifier, $note) { $client = $this->loadClientWC('match'); $param = new stdClass(); $param->matchIdentifierList->matchIdentifiers->matchIdentifier = $matchIdentifier; $param->note = $note; try { return $client->acknoledge($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * addNote * @param string matchIdentifier * @param string note * @return object */ public function addNote($matchIdentifier, $note) { $client = $this->loadClientWC('match'); $param = new stdClass(); $param->matchIdentifierList = new stdClass(); $param->matchIdentifierList->matchIdentifiers = new stdClass(); $param->matchIdentifierList->matchIdentifiers->matchIdentifier = $matchIdentifier; $param->note = $note; try { return $client->addNote($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getDetailsMatch * @param string matchIdentifier * @return object */ public function getDetailsMatch($matchIdentifier) { $client = $this->loadClientWC('match'); $param = new stdClass(); $param->matchIdentifier = $matchIdentifier; try { return $client->getDetails($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getNewUpdatedNameModel * @param string groupIdentifier * @return object */ public function getNewUpdatedNameModel($groupIdentifier) { $client = $this->loadClientWC('match'); $param = new stdClass(); $param->groupIdentifier = $groupIdentifier; try { return $client->getNewUpdatedNameModel($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getNewUpdatedNameModelForAllGroups * @return object */ public function getNewUpdatedNameModelForAllGroups() { $client = $this->loadClientWC('match'); try { return $client->getNewUpdatedNameModelForAllGroups()->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getNewUpdatedNameModelGroups * @return object */ public function getNewUpdatedNameModelGroups() { $client = $this->loadClientWC('match'); try { return $client->getNewUpdatedNameModelGroups()->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * getNewUpdatedNames * @param object $data * @return object */ public function getNewUpdatedNames($data) { $client = $this->loadClientWC('match'); $param = new stdClass(); //to be continued try { return $client->getNewUpdatedNames($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } /** * resolve * @param object $data * @return object */ public function resolve($data) { $client = $this->loadClientWC('match'); $param = new stdClass(); $param->matchIdentifierList->matchIdentifiers->matchIdentifier = $data->matchIdentifier; $param->matchRisk = $data->matchRisk; $param->matchStatus = $data->matchStatus; $param->note = $data->note; try { return $client->resolve($param)->return; } catch (SoapFault $fault) { if ($fault->faultcode){ return $fault->faultstring; } else { echo $client->__getLastResponse(); return false; } } } }