1. route:
Router::connect('/sms_gateway', array('controller' => 'SMS', 'action' => 'receiveMO'));Router::connect('/soap/:controller/:action/*', array('prefix'=>'soap', 'soap'=>true));
2. Server code:
App::uses('AppController', 'Controller');App::import('Vendor','nusoap/nusoap');class SMSController extends AppController {public $name = 'SMS';public $uses = array();public $autoRender = false;public $layout = false;function receiveMO(){$server = new soap_server();$namespace = false;$soapaction = 'http://pay.idivu.com/soap/SMS/smsIn';$endpoint = 'http://pay.idivu.com/soap/SMS';$server->configureWSDL('smsIn',$namespace,$soapaction);$server->register("smsIn", array('User_Id' => 'xsd:string','Service_Id'=>'xsd:string','Request_Id'=>'xsd:string','Command_Code'=>'xsd:string','Message'=>'xsd:string','User'=>'xsd:string','Pass'=>'xsd:string'),array('ketqua' => 'xsd:int'), $namespace, $soapaction,'rpc','literal','idivu.com');$query = isset($HTTP_RAW_POST_DATA)? $HTTP_RAW_POST_DATA : '';$server->service($query);exit();}function soap_smsIn($userId,$serviceId,$request_id,$command_code,$info,$user,$pass){// code here}}
3. Client code:
require_once 'nusoap/nusoap.php';
$svTest = new SoapClient("http://pay.idivu.com/sms_gateway?wsdl");
$result = $svTest->smsIn("0123456789","8888","0","KH","KH AT","user","pass");
print_r($result);
when i run "http://pay.idivu.com/sms_gateway?wsdl", result is an xml document.
But when i run client code, it returns error:
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in...
pls help me how to use nusoap to build webservice as a cakephp controller.
Tks.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
No comments:
Post a Comment