Service side: Phprpc Service side
<?PHP/*PHPRPC Server Demo * time:2014-06-23*/ require_once' phprpc_server.php ';//Introduction to the service side classTest {//generate a class Public functionGet$data= ' Java '){ return' Hello '.$data; } } $handle=NewPhprpc_server ();//instantiating the service side $handle->add (' Get ', ' test ');//add a Get method in the test class $handle->start ();//Handshake started?>
Service side: SOAP Service side
<?PHP/*SOAP Service Side demo * time:2014-06-23*/ classTest {//generate a class Public functionGet$data= ' Java '){ return' Hello '.$data; } } $config=Array( ' Location ' = ' http://127.0.0.1/soap_server.php ', ' uri ' = ' soap_server.php ' ); $handle=NewSoapServer (NULL,$config);//instantiating the service side $handle->setclass (' Test ');//Add the entire test class $handle->handle ();//Handshake started?>
Client: PHPRPC Client
<? PHP /* PHPRPC Client Demo * time:2014-06-23 */ require_once ' phprpc_client.php '; Introducing the client $handlenew phprpc_client (' http://127.0.0.1/server.php '); Instantiate the client and pass in the server-side URL echo$handle->get (' php!! '); // call the Get function ?>
Client: SOAP Client
<? PHP /* SOAP Client Demo * time:2014-06-23 * /$configarray( ' Location ' = ' http://127.0.0.1/soap_server.php ', ' uri ' = ' soap_server.php ' ); $handle New SoapClient (null,$config); ECHO $handle->get (' java!! ' );? >
Personal humble Opinion: Plainly, both are transmitted by serializing the data, and the performance situation is almost identical to the operating code, and there are many other ways to implement the Webserver function:; the fact that as far as I am concerned, I just need to know some of the principles and use one.