PHP using XML-RPC to construct WebService simple entry _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PHP uses XML-RPC to construct WebService simple entry. At present, there are two protocol standards for WebService 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 some need to stabilize the current Web Service communication has two protocol standards, one is XML-RPC, the other is SOAP. XML-RPC is relatively simple, the appearance of time is relatively early, SOAP is more complex, mainly in some need of stability, robustness, security and complex interaction when using.

PHP integrates access to both XML-RPC and SOAP protocols, both of which are concentrated in xmlrpc extensions. In addition, in php pear, whether PHP 4 or PHP 5, has been integrated with the XML-RPC extension by default, and the extension has nothing to do with xmlrpc extension, can independently implement XML-RPC protocol interaction, if there is no xmlrpc extension, we recommend using the PEAR: XML-RPC extension.

Here we mainly use XML-RPC to briefly describe the Web Service interaction process, part of the content from the PHP Manual, more detailed content, it is recommended to refer to the manual.

Install xmlrpc extension

If the php extension of xmlrpc is not installed in your system, install it correctly.

On the Windows platform, first put the extension php_xmlrpc.dll under the PHP installation directory under the C: Windows or C: Winnt Directory (the extension of PHP4 is in the C: phpextensions Directory, PHP5 extension in the C: phpext directory), and in the C: Windowsphp. ini or C: Winntphp. remove the semicolon ";" in front of extension = php_xmlrpc.dll in ini, and restart the Web server and check if phpinfo () has a XML-RPC project to determine if the xmlrpc extension has been correctly installed.

On Unix/Linux platforms, if the xmlrpc extension is not installed, re-compile PHP and add the -- with-xmlrpc option to configure, and view phpinfo () check whether xmlrpc is installed properly.

(Note: The following operations are based on the normal installation of xmlrpc expansion. Be sure to install them correctly .)

XML-RPC working principle

XML-RPC is roughly the whole process is to use XML for communication. First, construct an RPC server for sending XML-encapsulated requests from the RPC client, and return the processing results to the RPC client in XML format, the client analyzes XML to obtain the data it needs.

The server side of the XML-RPC must have a ready-made function provided to the client to call, and the function and method in the request submitted by the client must be consistent with the server side, otherwise the desired result cannot be obtained.

The following is a simple code to describe the entire process.

XML-RPC practice

The server uses the xmlrpc_server_create function to generate a server, register the RPC calling interface to be exposed, accept the XML data POST from the RPC client, and process it, the processing result is displayed to the client in XML format.

The code is as follows: rpc_server.php


There are two protocol standards for communications between consumer Service: XML-RPC and SOAP. XML-RPC is relatively simple, the appearance of time is relatively early, SOAP is more complex, mainly some need stability...

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.