Index: pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php	(revision 470)
+++ pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php	(revision 483)
@@ -9,46 +9,13 @@
 class Viettel extends MX_Controller 
 {
+	
+	private $_server = null;
+	
 	function __construct() {
 		parent::__construct ();
-		
-		$this->nusoap_server = new soap_server ();
-		$this->nusoap_server->configureWSDL('messageReceiverWSDL','urn:messageReceiverWSDL');
-
-		$this->nusoap_server->soap_defencoding = 'UTF-8';		
-		$this->nusoap_server->methodreturnisliteral=TRUE;
-		
-		$this->nusoap_server->wsdl->addComplexType(
-				'messageReceiver',
-				'simpleType',
-				'struct',
-				'',
-				'SOAP-ENC:Array',
-				array(
-						'username'=>array('name'=>'username', 'type'=>'xsd:string'),
-						'password'=>array('name'=>'password', 'type'=>'xsd:string'),
-						'requestID'=>array('name'=>'requestID', 'type'=>'xsd:string'),
-						'userID'=>array('name'=>'userID', 'type'=>'xsd:string'),
-						'receiverID'=>array('name'=>'receiverID', 'type'=>'xsd:string'),
-						'serviceID'=>array('name'=>'serviceID', 'type'=>'xsd:string'),
-						'commandCode'=>array('name'=>'commandCode', 'type'=>'xsd:string'),
-						'contentType'=>array('name'=>'contentType', 'type'=>'xsd:string'),
-						'info'=>array('name'=>'info', 'type'=>'xsd:string'),
-						'receiveTime'=>array('name'=>'receiveTime', 'type'=>'xsd:string')
-				)
+		ini_set("soap.wsdl_cache_enabled","1");
+		$this->_server = new SoapServer(NULL,
+				array('soap_version' => SOAP_1_2, 'encoding' => 'UTF-8', 'uri' => 'http://tempuri.org/')
 		);
-		
-		$this->nusoap_server->register ( 'MOReceiver', 
-				array( 'username' => 'xsd:string',
-						'password' => 'xsd:string',
-						'requestID' => 'xsd:string',
-						'userID' => 'xsd:string',
-						'receiverID' => 'xsd:string',
-						'serviceID' => 'xsd:string',
-						'commandCode' => 'xsd:string',
-						'contentType' => 'xsd:string',
-						'info' => 'xsd:string',
-						'receiveTime' => 'xsd:string')
-				, array ('return' => 'xsd:string'),
-				'urn:messageReceiverWSDL',"urn:messageReceiverWSDL#MOReceiver","rpc","encoded");
 	}
 
@@ -56,14 +23,18 @@
 	{
 		if($this->uri->segment(4) == "wsdl") {
-			$_SERVER['QUERY_STRING'] = "wsdl";
+			header('Content-Type: text/xml; charset: utf-8');
+			$this->load->view('mowsdl');
 		} else {
-			$_SERVER['QUERY_STRING'] = "";
-		}
-		$this->nusoap_server->service(file_get_contents("php://input"));
+			header('Content-Type: text/html; charset: utf-8');
+			echo 'See service <a href="'.base_url().'violetservice/soanbai/mo/wsdl">WSDL page</a>';
+		}			
 	}
 	
 	public function mo() 
 	{	
-		function MOReceiver($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $contentType ,$info, $receiveTime){
+		function messageReceiver(){
+			$aryArgs = func_get_args();
+			list($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $contentType ,$info, $receiveTime) = $aryArgs;
+			
 			$msgType = '0'; //text message
 			$errCode = '1'; //#1:error; 1:Success;
@@ -78,4 +49,5 @@
 			if ($password != $mo_password) return '0|0|Password is not corrected!';
 			if (!$requestID) return '0|0|requestID is required!';
+			if ((int)$requestID != 4) return '0|0|requestID is not corrected!';
 			if (!$userID) return '0|0|UserID is required!';
 			if (!$serviceID) return '0|0|serviceID is required!';
@@ -96,5 +68,37 @@
 		}
 		
-		$this->nusoap_server->service(file_get_contents("php://input"));
+		$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 = '<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
+						   <S:Body>
+						      <messageReceiverResponse xmlns="http://tempuri.org/">
+						         <return>'.$aryOutput[1].'</return>
+						      </messageReceiverResponse>
+						   </S:Body>
+						</S:Envelope>';
+		
+				header('Content-Type: text/xml; charset: utf-8');
+				echo $xml;
+			}
+			else {
+				header('Content-Type: text/html; charset: utf-8');
+				echo 'See service <a href="'.base_url().'violetservice/soanbai/mo/wsdl">WSDL page</a>';
+			}
+		}
+		catch (Exception $e) {
+			$this->_server->fault('Sender', $e->getMessage());
+		}
 	}
 }
