note 101979 added to class.soapserver

From: Date: Fri, 21 Jan 2011 10:46:52 +0000
Subject: note 101979 added to class.soapserver
Groups: php.notes 
Request: Send a blank email to php-notes+get-175960@lists.php.net to get a copy of this message
Another simple example for SOAP_SERVER with errorhandling an params and wsdl: SERVER (soap_all_srv.php): <?php // PEAR::SOAP einbinden require_once "SOAP/Server.php"; $skiptrace =& PEAR::getStaticProperty('PEAR_Error', 'skiptrace'); $skiptrace = true; // Service-Class class mytimeserv { // __dispatch_map public $__dispatch_map = array (); // In/Out param -> __dispatch_map public function __construct() { $this->__dispatch_map["now"] = array ("in" => array("format" => "string"), "out" => array("time" => "string")); } // get back __dispatch_map in __dispatch public function __dispatch($methodname) { if (isset($this->__dispatch_map[$methodname])) { return $this->__dispatch_map[$methodname]; } return NULL; } // servicemthod with parameters function now ($format) { // formaterror? if (($format == null) || (trim($format) == "")) { // send errormessage return new SOAP_Fault("Kein Parameter angegeben","0815", "Client"); } date_default_timezone_set('Europe/Berlin'); $time = date ($format); // return SOAP-Obj. return (new SOAP_Value('time','string', $time)); } } // service-class $service = new mytimeserv(); // server $ss = new SOAP_Server(); // add service with name $ss->addObjectMap (&$service,"urn:mytimeserv"); // service or wsdl if (isset($_SERVER["REQUEST_METHOD"])&& $_SERVER["REQUEST_METHOD"] == "POST") { // postdata -> service $ss->service ($HTTP_RAW_POST_DATA); } else { // wsdl-param in url if (isset($_SERVER['QUERY_STRING']) && strcasecmp($_SERVER['QUERY_STRING'],'wsdl') == 0) { // DISCO_Server for WSDL require_once "SOAP/Disco.php"; $disco = new SOAP_DISCO_Server ($ss,"mytimeserv","My Time Service"); // set HTML-Header header("Content-type: text/xml"); // return wsdl print $disco->getWSDL (); } } ?> CLIENT (soap_all_client.php) (for wsdl: http://192.168.178.99/soap_all_srv.php?wsdl): <?php require_once "SOAP/Client.php"; // SOAP/WSDL $sw = new SOAP_WSDL ("http://192.168.178.99/soap_all_srv.php?wsdl"); // Proxy-Obj. $proxy = $sw->getProxy (); // servicemthod $erg = $proxy->now ("H:i:s"); // return print $erg."\n"; ?> ---- Server IP: 85.214.154.209 Probable Submitter: 95.117.231.205 ---- Manual Page -- http://www.php.net/manual/en/class.soapserver.php Edit -- https://master.php.net/note/edit/101979 Del: integrated -- https://master.php.net/note/delete/101979/integrated Del: useless -- https://master.php.net/note/delete/101979/useless Del: bad code -- https://master.php.net/note/delete/101979/bad+code Del: spam -- https://master.php.net/note/delete/101979/spam Del: non-english -- https://master.php.net/note/delete/101979/non-english Del: in docs -- https://master.php.net/note/delete/101979/in+docs Del: other reasons-- https://master.php.net/note/delete/101979 Reject -- https://master.php.net/note/reject/101979 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175960) next »