Esempio n. 1
0
 public function output()
 {
     if (is_array($this->_data)) {
         return XMLSerializer::generateValidXmlFromArray($this->_data, "response", "data");
     } else {
         if (is_object($this->_data)) {
             return XMLSerializer::generateValidXmlFromObj($this->_data, "response", "data");
         }
     }
 }
Esempio n. 2
0
 function output_xml()
 {
     $CI =& get_instance();
     $CI->load->helper('xml');
     $xml_generater = new XMLSerializer();
     $xml = $xml_generater->generateValidXmlFromObj($CI->response);
     header('Content-Type: text/xml');
     header($CI->response->meta->header);
     print_r($xml);
 }
Esempio n. 3
0
 public function getUserByUsername($apikey, $secret)
 {
     if (!JOM_SOCIAL) {
         return $this->getBaseUserByUsername($apikey, $secret);
     }
     $auth = new Auth($apikey, $secret);
     if ($auth->isAuthenticate()) {
         if (isset($_GET['username'])) {
             $username = $_GET['username'];
         } else {
             if (isset($_POST['username'])) {
                 $username = $_POST['username'];
             }
         }
     } else {
         $result = WSHelper::constructResult(500, 'APIKey and secret key does not match', "getUserByName");
         return $result->asXML();
     }
     if (!isset($username)) {
         $result = WebserviceHelper::constructResult(500, 'One of the required fields is not set', "getBaseUserById");
         return $result->asXML();
     }
     $db =& JFactory::getDBO();
     $sql = "SELECT `id` , `name` , `username` , `email` , `usertype` ,\r\n\t\t\t\t\tSTATUS , points, avatar, thumb, friendcount\r\n\t\t\t\t\tFROM jos_users, jos_community_users\r\n\t\t\t\t\tWHERE jos_users.id = jos_community_users.userid and jos_users.username='******'";
     $db->setQuery($sql);
     $user = $db->loadObject();
     //$user->thumb = 'http://'.$_SERVER["SERVER_NAME"].'/'.$user->thumb;
     //$user->avatar = 'http://'.$_SERVER["SERVER_NAME"].'/'.$user->avatar;
     //$user->fields = $this->_getUserFields($username, 'username') ;
     if ($db->getErrorNum()) {
         $result = WebserviceHelper::constructResult(500, $db->stderr(), "getUserByName");
         return $result->asXML();
     } else {
         $user->thumb = 'http://' . $_SERVER["SERVER_NAME"] . '/' . $user->thumb;
         $user->avatar = 'http://' . $_SERVER["SERVER_NAME"] . '/' . $user->avatar;
         $fields = $this->_getUserFields($username, 'username');
         $this->_renderFields($fields, $user);
         //print_r($user);
         //die();
         $string = XMLSerializer::generateValidXmlFromObj($user, 'user_data');
         $result = WebserviceHelper::constructResultData(200, 'User Object Loaded', $string, "getUserByName");
         return $result->asXML();
     }
 }
Esempio n. 4
0
 /** Generic function for all needed SOAP calls **/
 public function soapCall($operation, $parameters = NULL)
 {
     //var_dump($operation);
     //set client parameter depending on $operation
     switch ($operation) {
         case 'Cancel':
         case 'GetExperimentStatus':
         case 'RetrieveResult':
             if ($parameters !== NULL) {
                 $params = array('experimentID' => $parameters['experimentID']);
             } else {
                 return $this->genXMLresp('exception', 'Parameters missing.');
             }
             break;
         case 'GetLabConfiguration':
         case 'GetLabStatus':
             $params = array('labServerID' => self::LS_ID);
             break;
         case 'Submit':
             if ($parameters !== NULL) {
                 $params = array('labServerID' => self::LS_ID, 'experimentSpecification' => $parameters['experimentSpecification'], 'priorityHint' => 0, 'emailNotification' => false);
             } else {
                 return $this->genXMLresp('exception', 'Parameters missing.');
             }
             break;
         default:
             return $this->genXMLresp('exception', 'SOAP operation unknown.');
             break;
     }
     //make a SOAP call
     //TODO: try out what happens, if server not responding (make local WSDL file and change name)
     $SOAPresp = $this->client->__soapCall($operation, array('parameters' => $params));
     //check for soap:Fault
     if (is_soap_fault($SOAPresp)) {
         $resp_type = 'soapFault';
         //TODO: $result durch $SOAPresp ersetzen. Im Moment dient es zum Test des Error-Handlers...
         $msg = '<soapFault><faultcode>' . $SOAPresp->faultcode . '</faultcode><faultstring>' . $SOAPresp->faultstring . '</faultstring></soapFault>';
         // Faultactor not always defined... causes Notice message!
         //+ '<faultactor>'.$SOAPresp->faultactor.'</faultactor><detail>'.$SOAPresp->detail.'</detail>'
         //+ '</soapFault>';
         //DEBUG
         //$msg .= PHP_EOL . PHP_EOL .'<SubmitSpec>'. PHP_EOL . htmlentities(str_replace('><','>'.PHP_EOL.'<',$this->genSubmitSpec($settings))) . PHP_EOL . '</SubmitSpec>'.PHP_EOL . PHP_EOL;
         $getLastRequest = $this->client->__getLastRequest();
         //$sxe = new SimpleXMLElement($getLastRequest);
         //$child = $sxe->children('Envelope',TRUE)->children();
         //echo '<pre>'.$getLastRequest.'</pre>';
         //$msg .= PHP_EOL . PHP_EOL . '<getLastRequest>'.htmlentities(str_replace('><','>'.PHP_EOL.'<',$getLastRequest)).'</getLastRequest>';//cannot be parsed in JS
         //$msg .= '<lastRequest>'.$sxe.'</lastRequest>';
         //DEBUG END
         //create return message
         return $this->genXMLresp($resp_type, $msg, $operation);
     } else {
         //success
         $resp_type = 'success';
         //TODO: Current types exception,soapFault und success. Maybe use 'soapEnvelope' instead of 'success'...
         $prop = $operation . 'Result';
         require_once dirname(__FILE__) . '/XMLSerializer.inc.php';
         //$myLogFile = fopen(dirname(__FILE__).'/LogFile.txt','w') or DIE('Unable to open file!');
         //fwrite($myLogFile, '$prop:' . PHP_EOL . $prop . PHP_EOL . PHP_EOL);
         //Check if var is object
         if (is_object($SOAPresp->{$prop})) {
             /*ob_start();
             		var_dump($SOAPresp->$prop);//no echo inside ob_start/end
             		$txt = ob_get_contents();
             		ob_end_clean();
             		fwrite($myLogFile, 'var_dump($SOAPresp->$prop):' . PHP_EOL . $txt . PHP_EOL);//*/
             //var_dump($SOAPresp->$prop);
             //---------------
             $xml_generator = new XMLSerializer();
             $std_class = json_decode(json_encode($SOAPresp->{$prop}));
             $xml = $xml_generator->generateValidXmlFromObj($std_class);
             echo $xml;
             //fwrite($myLogFile, 'var_dump($SOAPresp->$prop):' . PHP_EOL . $xml . PHP_EOL);
             //---------------
             //---------------
         } else {
             if (is_string($SOAPresp->{$prop})) {
                 $txt = $SOAPresp->{$prop};
                 echo $txt;
                 //fwrite($myLogFile, 'var_dump($SOAPresp->$prop):' . PHP_EOL . $txt . PHP_EOL);
             }
         }
         //echo $SOAPresp->$prop;
         //$sxe = new SimpleXMLElement( $SOAPresp->GetLabConfigurationResult );
         //$child = $sxe->children('labConfiguration',TRUE)->children();
         //$msg = $child->asXML();
         //strip response out of soap:Body
         //echo $this->client->__getLastResponse().'<br><br>';
         //$sxe = new SimpleXMLElement($this->client->__getLastResponse());
         //echo $sxe.'\n';
         //$child = $sxe->children('soap',TRUE)->children();
         //test
         //echo 'child:'.$child.'<<end';
         //SOAP-Body as response
         //$msg = $child->asXML();
         //Close File
         //fclose($myLogFile);
     }
     //create return message
     //return $this->genXMLresp($resp_type,$msg,$operation);
 }