Changeset 483 for pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php
- Timestamp:
- Nov 12, 2014 10:52:13 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php
r470 r483 9 9 class Viettel extends MX_Controller 10 10 { 11 12 private $_server = null; 13 11 14 function __construct() { 12 15 parent::__construct (); 13 14 $this->nusoap_server = new soap_server (); 15 $this->nusoap_server->configureWSDL('messageReceiverWSDL','urn:messageReceiverWSDL'); 16 17 $this->nusoap_server->soap_defencoding = 'UTF-8'; 18 $this->nusoap_server->methodreturnisliteral=TRUE; 19 20 $this->nusoap_server->wsdl->addComplexType( 21 'messageReceiver', 22 'simpleType', 23 'struct', 24 '', 25 'SOAP-ENC:Array', 26 array( 27 'username'=>array('name'=>'username', 'type'=>'xsd:string'), 28 'password'=>array('name'=>'password', 'type'=>'xsd:string'), 29 'requestID'=>array('name'=>'requestID', 'type'=>'xsd:string'), 30 'userID'=>array('name'=>'userID', 'type'=>'xsd:string'), 31 'receiverID'=>array('name'=>'receiverID', 'type'=>'xsd:string'), 32 'serviceID'=>array('name'=>'serviceID', 'type'=>'xsd:string'), 33 'commandCode'=>array('name'=>'commandCode', 'type'=>'xsd:string'), 34 'contentType'=>array('name'=>'contentType', 'type'=>'xsd:string'), 35 'info'=>array('name'=>'info', 'type'=>'xsd:string'), 36 'receiveTime'=>array('name'=>'receiveTime', 'type'=>'xsd:string') 37 ) 16 ini_set("soap.wsdl_cache_enabled","1"); 17 $this->_server = new SoapServer(NULL, 18 array('soap_version' => SOAP_1_2, 'encoding' => 'UTF-8', 'uri' => 'http://tempuri.org/') 38 19 ); 39 40 $this->nusoap_server->register ( 'MOReceiver',41 array( 'username' => 'xsd:string',42 'password' => 'xsd:string',43 'requestID' => 'xsd:string',44 'userID' => 'xsd:string',45 'receiverID' => 'xsd:string',46 'serviceID' => 'xsd:string',47 'commandCode' => 'xsd:string',48 'contentType' => 'xsd:string',49 'info' => 'xsd:string',50 'receiveTime' => 'xsd:string')51 , array ('return' => 'xsd:string'),52 'urn:messageReceiverWSDL',"urn:messageReceiverWSDL#MOReceiver","rpc","encoded");53 20 } 54 21 … … 56 23 { 57 24 if($this->uri->segment(4) == "wsdl") { 58 $_SERVER['QUERY_STRING'] = "wsdl"; 25 header('Content-Type: text/xml; charset: utf-8'); 26 $this->load->view('mowsdl'); 59 27 } else { 60 $_SERVER['QUERY_STRING'] = "";61 }62 $this->nusoap_server->service(file_get_contents("php://input"));28 header('Content-Type: text/html; charset: utf-8'); 29 echo 'See service <a href="'.base_url().'violetservice/soanbai/mo/wsdl">WSDL page</a>'; 30 } 63 31 } 64 32 65 33 public function mo() 66 34 { 67 function MOReceiver($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $contentType ,$info, $receiveTime){ 35 function messageReceiver(){ 36 $aryArgs = func_get_args(); 37 list($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $contentType ,$info, $receiveTime) = $aryArgs; 38 68 39 $msgType = '0'; //text message 69 40 $errCode = '1'; //#1:error; 1:Success; … … 78 49 if ($password != $mo_password) return '0|0|Password is not corrected!'; 79 50 if (!$requestID) return '0|0|requestID is required!'; 51 if ((int)$requestID != 4) return '0|0|requestID is not corrected!'; 80 52 if (!$userID) return '0|0|UserID is required!'; 81 53 if (!$serviceID) return '0|0|serviceID is required!'; … … 96 68 } 97 69 98 $this->nusoap_server->service(file_get_contents("php://input")); 70 $this->_server->addFunction('messageReceiver'); 71 try { 72 ob_start(); 73 $soapOutput = ''; 74 $this->_server->handle(); 75 76 if (ob_get_length() > 0) { 77 $soapOutput = ob_get_clean(); 78 } 79 80 if ($soapOutput != '') { 81 $pattern = '/<[^>]*[^\/]>/i'; 82 $aryOutput = preg_split ($pattern, $soapOutput, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); 83 84 $xml = '<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> 85 <S:Body> 86 <messageReceiverResponse xmlns="http://tempuri.org/"> 87 <return>'.$aryOutput[1].'</return> 88 </messageReceiverResponse> 89 </S:Body> 90 </S:Envelope>'; 91 92 header('Content-Type: text/xml; charset: utf-8'); 93 echo $xml; 94 } 95 else { 96 header('Content-Type: text/html; charset: utf-8'); 97 echo 'See service <a href="'.base_url().'violetservice/soanbai/mo/wsdl">WSDL page</a>'; 98 } 99 } 100 catch (Exception $e) { 101 $this->_server->fault('Sender', $e->getMessage()); 102 } 99 103 } 100 104 }
Note: See TracChangeset
for help on using the changeset viewer.