Using XML-RPC to construct a Web service simple _php Tutorial in PHP

Source: Internet
Author: User
Tags pear phpinfo
Currently there are two protocol standards for Web service communication, one is XML-RPC and the other is soap. XML-RPC is relatively simple, the occurrence of time is relatively early, soap is more complex, mainly some need to be stable, robust, secure and complex interaction when used.

PHP integrates access to XML-RPC and soap two protocols, all focused on xmlrpc extensions. In addition, in PHP pear, whether PHP 4 or PHP 5, has been integrated by default XML-RPC extension, and the extension is independent of xmlrpc extension, can independently implement the XML-RPC protocol interaction, if there is no xmlrpc extension, it is recommended to use pear:: XML-RPC extension.

We mainly use XML-RPC to describe the interactive process of Web service, part of the content from PHP manual, more detailed, recommended reference manual.

Installing the XMLRPC Extension

If you do not have a PHP extension for XMLRPC installed on your system, please install it correctly.

Under the Windows platform, first put the extension php_xmlrpc.dll under the PHP installation directory into the c:windows or c:winnt directory, (PHP4 extension in the C:phpextensions directory, PHP5 extension in C: Phpext directory), and extension=php_xmlrpc.dll the semicolon in front of the C:windowsphp.ini or C:winntphp.ini ";" Remove and then restart the Web server after viewing phpinfo () There is no XML-RPC project to be able to determine whether the XMLRPC extension is properly installed.

Under the Unix/linux platform, if the XMLRPC extension is not installed, recompile PHP, add the--WITH-XMLRPC option when configure, and check phpinfo () to see if XMLRPC is installed properly.

(Note: The following operations are based on the normal installation of XMLRPC expansion, please be sure to install correctly.) )

XML-RPC Working principle

Xml-rpc is roughly the whole process of using XML to communicate. The client then parses the XML to get the data it needs by constructing an XML-encapsulated request that is used by the RPC server to come out from the RPC client and return the processing results to the RPC client in XML form.

The server side of the XML-RPC must have out-of-the-box functions available to client calls, and the functions and methods in the request submitted by the client must be consistent with the server side, otherwise the desired result will not be obtained.

Here I carry out the simple code to describe the whole process.

XML-RPC Practice

The server side uses the Xmlrpc_server_create function to generate a server-side, then registers the RPC calling interface that needs to be exposed, accepts the XML data that the RPC client post, and then processes the result, which is displayed to the client in XML.

The code is as follows: rpc_server.php


http://www.bkjia.com/PHPjc/446650.html www.bkjia.com true http://www.bkjia.com/PHPjc/446650.html techarticle currently there are two protocol standards for Web service communication, one is XML-RPC and the other is soap. XML-RPC is relatively simple, the appearance of time is relatively early, soap is more complex, mainly need to stabilize ...

  • 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.