_server = new SoapServer(NULL, array('soap_version' => SOAP_1_2, 'encoding' => 'UTF-8', 'uri' => 'http://tempuri.org/') ); } public function index () { function messageReceiver() { $aryArgs = func_get_args(); list($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $contentType ,$info, $receiveTime) = $aryArgs; return '1|0|'.$commandCode.$serviceID; } $this->_server->addFunction('messageReceiver'); try { ob_start(); $soapOutput = ''; $this->_server->handle(); if (ob_get_length() > 0) { $soapOutput = ob_get_clean(); } if ($soapOutput != '') { $pattern = '/<[^>]*[^\/]>/i'; $aryOutput = preg_split ($pattern, $soapOutput, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $xml = ' '.$aryOutput[1].' '; header('Content-Type: text/xml; charset: utf-8'); echo $xml; } else { header('Content-Type: text/html; charset: utf-8'); echo 'See service WSDL page'; } } catch (Exception $e) { $this->_server->fault('Sender', $e->getMessage()); } } public function wsdl () { header('Content-Type: text/xml; charset: utf-8'); echo file_get_contents($this->_wsdl); } }