Created
December 2, 2010 05:08
-
-
Save stimms/724803 to your computer and use it in GitHub Desktop.
Soap definition for methods which call into Enform's services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
SOAP client to EnForm | |
This uses PHP5 built-in SoapClient | |
*/ | |
if(!defined("HSE_PATH")) define("HSE_PATH", str_replace("/utils/cw_soap","",dirname(__FILE__))); | |
class EnformSOAP { | |
private $wsdl = "http://enform.ca/externalCompletion/Service.svc?wsdl"; | |
private $auth = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"; | |
private $soap; | |
public $lastError; | |
public $lastResult; | |
// constructor | |
function EnformSOAP(){ | |
// disables WSDL cache while not testing | |
$ini = ini_set("soap.wsdl_cache_enabled", $this->LIVE); | |
$this->soap = new SoapClient($this->wsdl,array('soap_version' => SOAP_1_1)); | |
} | |
// generic SOAP call function | |
function Call($func,$params){ | |
try { | |
$this->LastResult = $this->soap->{$func}($params); | |
} | |
catch (SoapFault $soapFault) { | |
// if you have trouble debugging a failed call, try doing a var_dump($soapFault) to see everything that comes back | |
$this->lastError = "SOAP Fault: (faultcode: {$soapFault->faultcode}, faultstring: {$soapFault->faultstring})"; | |
$this->lastError .= "<br>Request : ".htmlentities($this->soap->__getLastRequest()); | |
$this->lastError .= "<br>Response : ".htmlentities($this->soap->__getLastResponse()); | |
} | |
return $this->LastResult->{$func."Result"}; | |
} | |
// ************** main Enform functions ****************** | |
function RegisterUserAndCourseCompletion($first, $last, $phone, $email, $addr, $city, $province, $country, $postal, $company, $position, $courseID, $mark, $modulesComplete){ | |
$OptionalModules = array(); | |
foreach ($modulesComplete as $mc) | |
$OptionalModules[] = new SoapVar($mc, XSD_STRING); | |
$param =array( | |
"firstName" => $first, | |
"lastName" => $last, | |
"enformID" => 0, | |
"eMail" => $email, | |
"province" => $province, | |
"address" => $addr, | |
"city" => $city, | |
"postalCode" => $postal, | |
"country" => $country, | |
"phoneNumber" => $username, | |
"company" => $company, | |
"position" => $position, | |
"key" => $this->auth, | |
"courseNumber" => $courseID, | |
"grade" => $mark, | |
"completedModules" => $modulesComplete | |
); | |
$result = $this->Call("CreateStudentAndRegisterCompletion",$param); | |
return $result->Success;//true or false | |
} | |
function RegisterCourseCompletion($enformID, $courseID, $mark, $modulesComplete){ | |
$OptionalModules = array(); | |
foreach ($modulesComplete as $mc) | |
$OptionalModules[] = new SoapVar($mc, XSD_STRING); | |
$param =array( | |
"enformID" => $enformID, | |
"key" => $this->auth, | |
"courseNumber" => $courseID, | |
"grade" => $mark, | |
"completedModules" => $modulesComplete | |
); | |
$result = $this->Call("RegisterCompletion",$param); | |
return $result->Success;//true or false | |
} | |
function UpdateStudent($enformID, $first, $last, $phone, $email, $addr, $city, $province, $country, $postal, $company, $position){ | |
$param =array( | |
"firstName" => $first, | |
"lastName" => $last, | |
"enformID" => $enformID, | |
"eMail" => $email, | |
"province" => $province, | |
"address" => $addr, | |
"city" => $city, | |
"postalCode" => $postal, | |
"country" => $country, | |
"phoneNumber" => $username, | |
"company" => $company, | |
"position" => $position, | |
"key" => $this->auth | |
); | |
$result = $this->Call("UpdateStudent",$param); | |
return $result->Success; // true or false | |
} | |
function GetEnformID($first, $last, $postalCode) | |
{ | |
$param =array( | |
"firstName" => $first, | |
"lastName" => $last, | |
"postalCode" => $postal, | |
"key" => $this->auth | |
); | |
$result = $this->Call("GetEnformID",$param);//-1 if not found, some number >0 otherwise | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment