Using PHPRPC and soap to implement PHP webserver function respectively

Source: Internet
Author: User
Tags soap soap client

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.