00001 <?php
00013 require_once("WSCORE2.php");
00014 require_once("soc1c.php");
00015
00016 if (file_exists("/info/www/soc/nusoap/lib/nusoap.php")) {
00017 require_once("/info/www/soc/nusoap/lib/nusoap.php");
00018 } else if (file_exists("../nusoap/lib/nusoap.php")) {
00019 require_once("../nusoap/lib/nusoap.php");
00020 } else if (file_exists("nusoap/lib/nusoap.php")) {
00021 require_once("nusoap/lib/nusoap.php");
00022 }
00023
00024
00029 class AIS_SOAP_WS extends SOC_Widget {
00033 function AIS_SOAP_WS($conf) {
00034 SOC_Widget::SOC_Widget($conf);
00035 }
00036
00049 function xmlFromSoap($service,$term,$code) {
00050 $namespace = $this->get("soc_namespace");
00051 $soc_wsdl = $this->get("soc_wsdl");
00052 $iui_wsdl = $this->get("iui_wsdl");
00053 $soapaction = $namespace.$service;
00054
00055 $xml = "";
00056
00057 $client = new nusoap_client($soc_wsdl);
00058
00059
00060 switch ($service) {
00061 case 'GetBioLink':
00062
00063
00064 $envelope = "<GetBioLink xmlns=\"$namespace\"><strInstEmpID>$code</strInstEmpID></GetBioLink>";
00065
00066 $mysoapmsg = $client->serializeEnvelope($envelope,'',array(),'document', 'literal');
00067
00068 $response = @ $client->send($mysoapmsg, $soapaction);
00069 if ($client->fault) {
00070 $this->error("Client failed in $service ".$client->fault);
00071 } else if (! isset($response['GetBioLinkResult'])) {
00072 $this->error("$service failed, check $soc_wsdl");
00073 } else {
00074 $xml = $response["GetBioLinkResult"];
00075 }
00076 break;
00077 case 'GetSOCTerms':
00078 $envelope = "<$service xmlns=\"$namespace\" />";
00079
00080 $mysoapmsg = $client->serializeEnvelope($envelope,'',array(),'document', 'literal');
00081
00082 $response = @ $client->send($mysoapmsg, $soapaction);
00083 if ($client->fault) {
00084 $this->error("Client failed in $service ".$client->fault);
00085 } else if (! isset($response['GetSOCTermsResult'])) {
00086 $this->error("$service failed, check $soc_wsdl");
00087 } else {
00088 $xml = $response["GetSOCTermsResult"];
00089 }
00090 break;
00091 case 'GetIUITerms':
00092 $envelope = "<GetIUITerms xmlns=\"$namespace\" />";
00093
00094 $mysoapmsg = $client->serializeEnvelope($envelope,'',array(),'document', 'literal');
00095
00096 $response = @ $client->send($mysoapmsg, $soapaction);
00097 if ($client->fault || isset($response['faultstring'])) {
00098 $this->error("Client failed in $service ".$client->fault." ".$response['faultstring']);
00099 } else if (! isset($response['GetIUITermsResult'])) {
00100 $this->error("$service failed, check $soc_wsdl");
00101 } else {
00102 $xml = $response["GetIUITermsResult"];
00103 }
00104 break;
00105 case 'GetDeptList':
00106 $envelope = "<GetDeptList xmlns=\"$namespace\"><strTerm>".$term.'</strTerm></GetDeptList>';
00107
00108 $mysoapmsg = $client->serializeEnvelope($envelope,'',array(),'document', 'literal');
00109
00110 $response = @ $client->send($mysoapmsg, $soapaction);
00111
00112 if ($client->fault) {
00113 $this->error("Client failed in $service ".$client->fault);
00114 } else if (! isset($response['GetDeptListResult'])) {
00115 $this->error("$service failed, check $soc_wsdl");
00116 } else {
00117 $xml = $response["GetDeptListResult"];
00118 }
00119 break;
00120 case 'GetCourseList':
00121 $strPrefixType = 'N';
00122
00123 $envelope = "<GetCourseList xmlns=\"$namespace\"><strTerm>".$term.'</strTerm><strPrefixCode>'.$code.'</strPrefixCode><strPrefixType>'.$strPrefixType.'</strPrefixType></GetCourseList>';
00124
00125 $mysoapmsg = $client->serializeEnvelope($envelope,'',array(),'document', 'literal');
00126
00127
00128 $response = @ $client->send($mysoapmsg, $soapaction);
00129
00130 $xml = "";
00131 if ($client->fault) {
00132 $this->error("Client failed in $service ".$client->fault);
00133 } else if (isset($response['GetCourseListResult'])) {
00134 $xml = str_replace('<?xml version="1.0" encoding="utf-16"?>','',$response["GetCourseListResult"]);
00135 }
00136
00137 if (strpos($xml,'syllabus') === false) {
00138
00139 $strPrefixType = 'C';
00140 $envelope = "<GetCourseList xmlns=\"$namespace\"><strTerm>".$term.'</strTerm><strPrefixCode>'.$code.'</strPrefixCode><strPrefixType>'.$strPrefixType.'</strPrefixType></GetCourseList>';
00141
00142 $mysoapmsg = $client->serializeEnvelope($envelope,'',array(),'document', 'literal');
00143
00144
00145 $response = @ $client->send($mysoapmsg, $soapaction);
00146
00147 if ($client->fault) {
00148 $this->error("Client failed in $service ".$client->fault);
00149 } else if (! isset($response['GetCourseListResult'])) {
00150 $this->error("$service failed, check $soc_wsdl");
00151 } else {
00152 $xml = str_replace('<?xml version="1.0" encoding="utf-16"?>','',$response["GetCourseListResult"]);
00153 }
00154 }
00155 break;
00156 case 'GetSyllabus':
00157 $section = $code;
00158 $envelope = '<GetSyllabus xmlns="'.$namespace.'"><strTerm>'.$term.'</strTerm><strSectionID>'.$section.'</strSectionID></GetSyllabus>';
00159 $mysoapmsg = $client->serializeEnvelope($envelope,'',array(),'document', 'literal');
00160 $response = @ $client->send($mysoapmsg, $soapaction);
00161 if ($client->fault) {
00162 $this->error("Client failed in $service $envelope ".$client->fault);
00163 } else if (! isset($response['GetSyllabusResult'])) {
00164 $this->error("$service failed, check $soc_wsdl");
00165 } else {
00166 $xml = $response["GetSyllabusResult"];
00167 }
00168 break;
00169 case 'GetSessionInfo':
00170
00171 $client = new nusoap_client($soc_wsdl);
00172 $session = $code;
00173 $envelope = '<GetSessionInfo xmlns="'.$namespace.'"><strTerm>'.$term.'</strTerm><strSession>'.$session.'</strSession></GetSessionInfo>';
00174
00175 $mysoapmsg = $client->serializeEnvelope($envelope,'',array(),'document', 'literal');
00176
00177
00178 $response = @ $client->send($mysoapmsg, $soapaction);
00179
00180 if ($client->fault) {
00181 $this->error("Client failed in $service ".$client->fault);
00182 } else if (! isset($response['GetSessionInfoResult'])) {
00183 $this->error("$service failed, check $soc_wsdl");
00184 } else {
00185 $xml = $response["GetSessionInfoResult"];
00186 }
00187 break;
00188 default:
00189 $this->error("$service not supported");
00190 break;
00191 }
00192
00193 if ($this->errorCount() == 0) {
00194
00195
00196 $cache_id = trim($service . ':' . $term . ':' . $code);
00197 $sql = 'REPLACE INTO soap_xml_cache (cache_id, service, term, code, xml) VALUES ("' . $cache_id . '","' . $service . '","' . $term .'","' . $code . '","'. addslashes($xml) . '")';
00198 $db = new WSCORE2($this);
00199 $db->open();
00200 $db->execute($sql);
00201
00202
00203
00204
00205 if (strpos($xml, '&quot;')) {
00206 $tmp = str_replace('&quot;','"', $xml);
00207 $xml = $tmp;
00208 }
00209
00210 return $xml;
00211 }
00212 return false;
00213 }
00214 }
00215
00216
00217
00218 ?>