AnsweredAssumed Answered

Is it possible to call an external web service from a Logic Hook? PHP5

Question asked by Jan Rehorik on Sep 8, 2016
Latest reply on Sep 9, 2016 by Offshore Evolution

I have been trying to make a call from a Logic Hook to an external web service.  This code works when not in the Logic Hook (the non-bean stuff at least). Using "After_Save" on the Contacts module I get a 500 error without more description.

 

<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class DOTSAV3Contact
{
function av3($bean, $event, $arguments)
{
$id = $bean->id;
$Output = "";

$wsdlUrl = "https://trial.serviceobjects.com/AV3/api.svc?wsdl";

$backupWsdlUrl = "https://trial.serviceobjects.com/AV3/api.svc?wsdl";

$Business = "";
$Address = $bean->primary_address_street;
$Address2 = "";
$City = $bean->primary_address_city;
$State = $bean->primary_address_state;
$PostalCode = $bean->primary_address_postalcode;
$LicenseKey = "XXXX-XXXX-XXXX";

$params['Business'] = $Business;
$params['Address'] = $Address;
$params['Address2'] = $Address2;
$params['City'] = $City;
$params['State'] = $State;
$params['PostalCode'] = $PostalCode;
$params['LicenseKey'] = $LicenseKey;


try
{
$soapClient = new SoapClient($wsdlUrl, array( "trace" => 1 ));
$result = $soapClient->GetBestMatches($params);
if(isset($result->GetBestMatchesResult->Error) && $result->GetBestMatchesResult->Error->TypeCode == 3)
{
throw new Exception;
}
}
catch(Exception $e)
{
}
$query = "update contacts set description='".$Output."' where id='".$id."'";
$result = $bean->db->query($query);
return;
}
}
?>

Outcomes