Tutorials to .com

Tutorials to .com » Php » Xml » The use of XML in PHP remote service technology structure (I)

The use of XML in PHP remote service technology structure (I)

Print View , by: iSee ,Total views: 9 ,Word Count: 2126 ,Date: Thu, 16 Apr 2009 Time: 1:18 AM

The future will be based on Web services-centric Web, XML_RPC make the preparation and application of standards of service has become very simple. This article describes the realization of XML_RPC standards and PHP, and through examples of how the model developed in the php client services and XML_RPC.

A Web service
Content providers from the simple method used by the UDDI (Universal Description, Discovery and Integration) concept of the future, the industry has a large number of "service Web" notes and comments. On the Web start-up phase, it is only a distribution center for documentation, just trying to give some information can be found. With the Web's development, and run Web services in the increasingly attractive. The future, Web will become the Enterprise to customers and other businesses provide convenient services to the carrier. B2B and B2C model can be inter-collaborative service as a Web.

A very important question is, Web on how to provide what services? Web services can provide many, some of which are now in the use of services, some services in the near future will appear. In order to illustrate the problems listed below can be a small part of the services provided through the Web:

Subject-oriented vertical search engines.
For users of the Knowledge Base to find information.
Users can ask the question of the expert system.
Banking services.
News and information publishing services.
digital pay-related services.
Graphics processing services.
Health and health services.

In that case, businesses and organizations to provide services through the Web the right way to what is it? This is a very important issue. Today, some service providers HTML interface, they adopted the form of documents, but in the service interface behind what? Web in the occupation of the race, Web browsers are not alone, mobile phones, handheld devices, as well as equipment such as microwave ovens want to visit the Web, query the database, convert data, extract information, and so on. To achieve true service Web, in the presentation layer (HTML) should be there is another layer under.

Second, XML_RPC standards
xml is perhaps the last 10 years, the most important standards, xml vocabulary (Vocabulary) for the enterprise structure provides the cornerstone of service environment. To build a Web service standards XML_RPC there is a need to study, not only because XML_RPC for services on the Web on the very useful, but because a XML_RPC has been formed, it is easy to adopt standards. B2B services for the services provided, the standard is extremely important to follow common standards companies can make use of the services provided by other companies access to rapid growth. Can not imagine the service in a variety of private standards can be a real service to build Web, services must have a standard that can be followed.

XML_RPC is an Internet-oriented distributed processing standards. RPC is Remote Procedure Call (RPC) of the abbreviation, it is a mechanism for long-distance calls for the call may reside in other machines may be used on other languages as well as the process of preparation. Remote Procedure Call is an important pillar of distributed computing. For example, in a distributed computing environment, we can find and use in other machines running on the implementation of the operation of addition and subtraction process, the implementation of the process of addition operations may be prepared by APL, RS6000 machines in operation, the implementation of the process of subtraction operation c may be prepared to run in Unix. Other use of this distributed the same calculator can be used to develop them, or he could choose another calculator better.

In RPC, the process (Procedure) is the most important components, the server is provided for the process of client-side call. Process can receive parameters and return results. HTTP as a protocol to XML_RPC carrier, send and receive data through the xml vocabulary achieve the RPC mechanism. Server and client must be in accordance with the requirements of the standard XML_RPC response and request processing.

Third, XML_RPC agreement XML_RPC complete specification <br> can find http://www.xmlrpc.com/spec. The following is a description of its main points.

3.1 XML_RPC request

XML_RPC requests should be HTTP POST request, it is the XML format of the text. Part of the XML format of the request are as follows:

<? Xml version = "1.0"?>
<methodCall>
<methodName> Examples.getStateName </ methodName>
<params>
<param>
<value> <i4> 41 </ i4> </ value>
</ Param>
</ Params>
</ MethodCall>

Specify where the data is sent to the URL is not specified here. If the RPC server is specifically designed to deal with, it may be "/." The above XML document is a payload of "methodCall" structure. methodCall must contain a "methodName" sub-elements, "methodName" sub-element contains a description of methods to be called the string. How to interpret "methodName" the contents of the decision by the server, for example, the implementation of it can be a file name, can be recorded in the database name, or any other thing. If the process of receiving parameters, "methodCall" may contain a "params" element, as well as a number of "param" sub-elements. Every "param" element contains a descriptor with the value type, the type descriptor as follows:

Tags Description
<i4> Or <int> Four-byte signed integer, such as 12
<boolean> 0 (false), or 1 (true)
<string> String, such as "Hello World"
<double> Double-precision floating-point numbers with symbols, such as the -12.214
<dateTime.iso8601> Date / Time, such as 19980717T14: 08:55
<base64> base64-encoded binary data, such as eW91IGbid0IHJlQgdGhpcyE

3.1.1 Structure

Value can be a structure, structural elements used to describe <struct>. <struct> Each contain multiple <member>, each contains a <name> and <member> a <value>. The following is a structure consisting of two elements:

<struct>
<member>
<name> Name </ name>
<value> <string> Member1 </ string> </ value>
</ Member>
<member>
<name> Member2 </ name>
<value> <i4> 19 </ i4> </ value>
</ Member>
</ Struct>

<struct> can be nested arbitrarily <value> can contain arbitrary <struct> or other types, including <array>.

3.1.2 array

Value can be an array type, the array elements used to describe <array>. <array> Each element contains a <data> elements, <data> element which can contain any number of elements <value>. The following is an example of the array elements:

<array>
<data>
<value> <boolean> 0 </ boolean> </ value>
<value> <i4> 9 </ i4> </ value>
<value> <string> Hello </ string> </ value>
</ Data>
</ Array>

no name <array> elements. As shown in examples, <array> the value of the element can be of various types. <array> elements can be nested, any <value> or <array> can contain other types, such as described above <struct>.

3.2 XML_RPC response [/ b]

XML_RPC response is an HTTP response content type is text / xml. Response format of the text as follows:

<? Xml version = "1.0"?>
<methodResponse>
<params>
<param>
<value> <string> ABCDEFG </ string> </ value>
</ Param>
</ Params>
</ MethodResponse>

<methodResponse> may contain a <params> structure, or <fault> structure may contain a specific call from the success of the decision process. XML structure and <params> the same request, <fault> syntax elements are as follows:

[TR]
<fault>
<value>
<struct>
<member>
<name> FaultCode </ name>
<value> <int> 4 </ int> </ value>
</ Member>
<member>
<name> FaultString </ name>
<value> <string> Error! </ String> </ value>
</ Member>
</ Struct>
</ Value>
</ Fault>

[AutoPage]


Php XML Application Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.