The future web of xml| remote services will be a service-centric WEB,XML_RPC standard that makes writing and application services very simple. This article describes the XML_RPC standard and its PHP implementation, and demonstrates how to develop XML_RPC services and client programs in PHP with examples.
One, service-style web
from the simple approach used by content providers to the future vision of UDDI (Universal description,discovery and integration), the industry already has a wealth of descriptions and comments about the "serviced Web". In the start-up phase of the Web, it is just a distribution center for a document, providing only some browsable information. With the development of the Web, running services on the web is becoming increasingly attractive. In the future, the web will become a carrier for customers and other enterprises to provide convenient services. Collaboration between Business-to-business and Business-to-consumer modes can be viewed as a service web.
A very important question is, what services can be provided on the Web? The web can provide a lot of services, some of which are already in use, and some services will be available in the near future. To illustrate the problem, a small subset of the services available through the Web are listed below:
Vertical search engine for themes. A knowledge base for users to find information. A user can consult an expert system for questions. Banking services. News and information Publishing services. Digital payment-related services. Graphics processing services. Health and health services.
So, what is the right way for businesses and organizations to deliver services through the Web? This is a very important question. Today, some services provide HTML interfaces that provide services in the form of documents, but what is hidden behind the service interface? In the race to occupy the Web, Web browsers are not alone, and devices such as mobile phones, handheld devices and microwaves want to access the Web, query the database, transform data, extract information, and so on. There should be another layer under the presentation layer (HTML) to implement the True Service Web.
Second, XML_RPC standard
XML is perhaps the most important standard in nearly 10 years, and the XML Glossary (vocabulary) provides a cornerstone for the enterprise to construct a service environment. It is necessary to learn XML_RPC standards to build a serviced web, not only because XML_RPC is useful for putting services on the web, but because Xml_rpc is an already-formed, easily adopted standard. For business-to-business services, the standard of service delivery is extremely important, and companies that follow standards can use the services provided by other companies to achieve rapid growth. It is impossible to imagine that a true service Web can be built on top of a variety of proprietary service standards, and that services must have a standard to follow.
Xml_rpc is a standard for Internet distributed processing. RPC is the abbreviation for remote Procedure call (remote procedure invocation), which is a remoting mechanism for invoking procedures that may reside on other machines and may be written in other languages. Remote procedure call is an important pillar of distributed computing. For example, in a distributed computing environment, we can look for and utilize the process of performing addition and subtraction operations on other machines, the process of performing addition operations may be written in APL, run on RS6000 machines, and the process of performing subtraction may be written in C and run on UNIX. Other developers who want to use this distributed calculator can also use them, or they can choose a better calculator.
in RPC, the process (Procedure) is the most important component, and the server provides a procedure for the client to invoke. Procedures can receive parameters and return results. XML_RPC uses HTTP as the protocol carrier to implement the RPC mechanism by sending and receiving the XML glossary of data. The XML_RPC server receives the XML_RPC request and returns the Xml_rpc answer, XML_RPC the client sends the XML_RPC request and receives the XML_RPC reply. The server and the customer must process the answers and requests as required by the XML_RPC standard.
III, XML_RPC Agreement
Complete XML_RPC specification can be found in Http://www.xmlrpc.com/spec. The following is a description of the key points.
3.1 XML_RPC Request
The
XML_RPC request should be an HTTP POST request, and its body is in XML format. The XML part of the request is formatted as follows:
>
Examples.getstatename
specifies where the URL to send the data is not specified here. If the server is dedicated to RPC processing, it may be "/". The payload in the XML document described above is a "methodcall" structure. Methodcall must contain a "methodname" child element, and the "methodname" child element contains a string that describes the method to be called. How to interpret the content of "MethodName" is entirely up to the server, for example, it can be the name of an execution file, the name that is recorded in the database, or anything else. If the procedure receives parameters, "Methodcall" can contain a "params" element and several "param" child elements. Each "param" element contains a value with a type descriptor, and the type descriptor is shown in the following table:
tag Description or <int> four-byte signed integer, such as <boolean> 0 (false), or 1 (true) <string> string, such as "Hello World" <double> Double-precision signed floating-point number, such as -12.214 <dateTime.iso8601> Date/time, such as 19980717t14:08:55 <base64> base64 encoded binary data, such as Ew91igbid0ihjlqgdghpcye
3.1.1 Structure
The
value can be a struct, and the structure is described with a <struct> element. Each <struct> contains multiple <member>, each <member> contains a <name> and a <value>. Here is a structure consisting of two elements:
name member1
Member2
<struct> can be nested, any <value> can include <struct> or any other type, including <array>.
3.1.2 Array
The
value can be an array type, and the array is described with a <array> element. Each <array> element contains a <data> element,<data> element that can contain any number of <value> elements. Here is an example of an array element:
<array> elements have no name. The value of the,<array> element, as shown in the preceding example, can be of various types. <array> elements can be nested, any <value> can contain <array> or other types, such as the <struct> described above.
3.2 Xml_rpc Answer [/b]
The
xml_rpc answer is an HTTP reply, and the content type is text/xml. The reply body is formatted as follows:
>
ABCDEFG
<methodResponse> may contain a <params> structure, or it may contain a <fault> structure, depending on whether the procedure call succeeds. The syntax of the <params> structure is the same as the,<fault> element in an XML request:
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.