BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
PHP XML
Simple XSLT transformation with PHP 4.1.0 and Sablotron
 
 

By :Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :03/19/2008
Times viewed :3842

 

PHP XML-RPC Introduction

What is XML-RPC?

RPC stands for Remore Procedure Call.

It is a set of specifications and implementations that makes applications running in different environments; different operating system can talk to each other by making remote procedure call. An RPC-based Web service is a collection of procedures that can be called by a remote client over the Internet. XML-RPC is the makes it easy for distributed systems and system interoperability. This allows a perl function to make a call to a Python method, or a Java Servlet to call a PHP function.

This makes a lot for heterogenous applications can talk to each other with little support from programmers. So once it is set then application can talk to any RPC enabled application irrespective of its programming language and environment.

PHP supports RPC by providing rich set of functions and apis. These functions can be used to create server as well as client. You can find more information about RPC on http://xmlrpc.com and more documentation on this extension and its functions at http://xmlrpc-epi.sourceforge.net/.

As of PHP 4.1.0, the XML-RPC extension is included in the source package with the status of experimental. This extension is simply a copy of the XML-RPC EPI extension that can be found at http://xmlrpc-epi.sourceforge.net/main.php?t=php_about

How to enable XML-RPC extension on PHP?

XML-RPC support in PHP is not enabled by default. To enable it you need to uncomment the appropriate extension dll in php.ini( for Windows environment, as of PHP5.0.3 it would be ;extension=php_xmlrpc.dll and you need to make it extension=php_xmlrpc.dll by removing ;(comma)).

An XML-RPC call is sent from a client to a server via HTTP POST. This allows XML-RPC applications to work fairly easily behind firewalls, as port 80 is almost always open.

Example of Request and Response


Here's a sample XML-RPC request:

POST /default/php/server.php HTTP/1.0

User_Agent: This is a Dummy Client

Host: localhost

Content-Type: text/xml

Content-Length: 193

<?xml version="1.0" encoding="iso-8859-1"?>

<methodCall>

<methodName>dummyserver</methodName>

<params>

<param>

<value>

<string>test1</string>

</value>

</param>

</params>

</methodCall>

The first part of the request is simply a standard HTML post request. It's the data sent in the body of the request that interests us.The <methodCall> tags simply encapsulate the call, with all the parameters enclosed in <params> and each parameter enclosed in <param>. The data types supported in XML-RPC are:

<i4> or <int>
four-byte signed integer
10
<boolean>
0 (false) or 1 (true)
1
<string>
ASCII string
Hello, Mr. John
<double>
double-precision signed 
floating point number
-21.2544
<dateTime.iso8601>
date/time
20011219T12:05:26
<base64>
base64-encoded binary
eW91IGNhbid0IHJlYWQgdGhpcyE=

In addition to the basic types, PHP also supports structs and arrays, <struct>s containing any number of <member>s that consist of <name>s and <value>s (specified in the same manner as <param>s):

<struct>
  <member>
  <name>name</name>
  <value>
  <string>Mr. John</string>
  </value>
  </member><member>
<name>title</name><value>
<i4>Rodrigo</i4> </value>
</member>
</struct>

and arrays merely containing any number of <value>s:

<array>
 <value><i4>10</i4></value>
 <value><i4>20</i4></value>
 <value><i4>30</i4></value>
</array>

Here's a sample XML-RPC response:

HTTP/1.1 200 OK

Date: Sat, 15 Jan 200516:24:16 GMT

Server: Apache/2.0.52 (Win32) PHP/5.0.3

X-Powered-By: PHP/5.0.3

Content-Length: 196

Connection: close

Content-Type: text/xml

<?xml version="1.0" encoding="iso-8859-1"?>

<methodResponse>

<params>

<param>

<value>

<string>Your request string contains test1.</string>

</value>

</param>

</params>

</methodResponse>


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

A great opportunity to Digital Vide
here is a greate opportunity as a S
A great opportunity as a Network En
A Greate Opportunituy as a SQL Deve
An immediate job opportunity as a B

View all Jobs (Add yours)
View all CV (Add yours)



Information Online

swimming pool contractor
chicago web site design
teleconferencing service
Web Hosting
spoc
Calvin klein sunglasses
answering service


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP