Latest

Archive

Community news

C++

Communities and Content

Databases

Editorials

Emacs

General

HTML

Java

Notices

PHP

XML

Apache

C++

Database

General

HTML

Java

Javascript

Linux

Object oriented programming

Open source

Perl

PHP

Python

Ruby

SOAP

XML

Suggest a link

Advertise on zez

Contribute

Contact us

About zez


Communicating with XML-RPC



This article (En Español) will show you an easy way to write a simple XML-RPC server and client using the eZ xmlrpc software package available from developer.ez.no.

What is XML-RPC?


XML-RPC is a Remote Procedure Calling protocol that works over the Internet using HTTP as a transport agent. The requests and responses are defined in XML. For the XML-RPC spec go to XML-RPC spec.

This protocol enabled communication over different operating systems using different programming languages.


The server


The code snippet below shows how you can implement a simple server using eZ xmlrpc. The server has one function, "myFunc", which returns a text string. This is the simplest example of the implementation of a server.


ob_start();

// include the server
include_once( "ezxmlrpc/classes/ezxmlrpcserver.php" );

// include the datatype(s) we need
include_once( "ezxmlrpc/classes/ezxmlrpcstring.php" );

$server = new eZXMLRPCServer( );

$server->registerFunction( "myFunc" );

// process the server requests
$server->processRequest();

function myFunc( )
{
    return new eZXMLRPCString( "This command was run by xml rpc" );
}

ob_end_flush();


As you can see you only have to create a function and register the function with the server with the $server->registerFunction() function. To implement the function you write a normal php function which returns a valid eZXMLRPC datatype; eZXMLRPCInt, eZXMLRPCString, eZXMLRPCBool, eZXMLRPCDouble, eZXMLRPCBase64, eZXMLRPCArray or eZXMLRPCStruct.

If you want to have parameters to the function you can add this with the second argument to registerFunction().

To register a function which takes an argument of the type int you write the code shown below. You can add as many parameters as you want.


// register the function
$server->registerFunction( "foo", array( new eZXMLRPCInt() ) );

// implement the function
function foo( $args )
{
    $tmp = new eZXMLRPCString( "You sendt me: " . $args[0]->value() );
    return $tmp;
}



| < 1 > | 2 | 3 | Next page >> | Printer-friendly page |

Comment List


Topic: Author:
Time:
$domTree =& qdom_tree( $stream ); Shawn Vose 29.01.2003 19:52

I just started messing around with this and I am curious to know of a work around for this error.
Fatal error: Call to undefined function: qdom_tree() in /home/httpd/httpdocs/ezxmlrpc/classes/ezxmlrpcresponse.php on line 71

Any suggestions?


   RE: $domTree =& qdom_tree( $stream ); Shawn Vose 29.01.2003 20:03

> I just started messing around with this and I am curious to
> know of a work around for this error.
> Fatal error: Call to undefined function: qdom_tree() in
> /home/httpd/httpdocs/ezxmlrpc/classes/ezxmlrpcresponse.php
> on line 71
>
> Any suggestions?

Also I have the php 4.2.2 installed


Visual Basic Client pedro dulce 16.06.2001 17:01

Hi,
I´m looking for a xml-rpc library for Visual Basic, that lets me programm a client.
My xml-rpc server is implemented in java.
Thanks


Help? Matthew Casebeer 05.06.2001 17:04

I have been trying to get eZ xmlrpc working for two days now. I have been able to get php 4.0.4 and .5 working on Apache and PWS. yet when i try to do anything with eZ xmlrpc i get the following error

Fatal error: Call to undefined function: qdom_tree() in d:Inetpubwwwrootezxmlrpcclassesezxmlrpcresponse.php on line 71

is there something i need to do to get qdom_tree() to be regonized.

Matthew Casebeer


qdom support - what is it paul smith 16.02.2001 14:03

I am new to PHP so forgive me for asking a stupid question.
I am looking for an XML-RPC API for PHP and this one looks good.

I was wondering what the requirement for qdom support is - is it a new add-on for PHP 4.0.4???

Also, when will the next release be of the API? will it be a non-beta?

Thanks,

Paul.


   RE: qdom support - what is it paul smith 16.02.2001 16:47

Ah, found it out myself, yes it is part of PHP 4.0.4

&gt; I am new to PHP so forgive me for asking a stupid question.
&gt; I am looking for an XML-RPC API for PHP and this one looks good.
&gt;
&gt; I was wondering what the requirement for qdom support is - is it a new add-on for PHP 4.0.4???
&gt;
&gt; Also, when will the next release be of the API? will it be a non-beta?
&gt;
&gt; Thanks,
&gt;
&gt; Paul.


Differences between ZEZ and Usefulinc.com Jose Landivar 08.02.2001 08:08

Hi, I am just trying to understand what is different between ZEZ's implementation of the xmlrpc standard proposal and Usefulinc.com's implementation of it. I have written some code using the latter but am asking myself whether this is just another implementation of the same standard with the same features.

Actually, one thing that would make this a winner would be native support for HTTPS (HTTP over SSL/STL). Now that would be cool to have right off the bat.

Another thing is.. do you guys know of any Perl implementation of the standard with HTTPS support natively?.

Jose' L. Landivar


   RE: Differences between ZEZ and Usefulinc.com Bård Farstad 15.02.2001 14:57

&gt; Hi, I am just trying to understand what is different between ZEZ's implementation of the xmlrpc standard proposal and
&gt; Usefulinc.com's implementation of it. I have written some code using the latter but am asking myself whether this is
&gt; just another implementation of the same standard with the same features.

It's just an alternative implementation. It is more object oriented, but it has the same features.

As for the SSL, the simplest would be to set up SSH port forwarding probably. (That's what I use). To enable it to be used as an SSL client I have to implement support for curl or something like that.


     RE: Differences between ZEZ and Usefulinc.com bork azoid 02.11.2001 03:11

> It's just an alternative implementation. It is more object
> oriented, but it has the same features.

Does it have the same bug about 32k http headers?

I *think* this is what is causing me great problems. working with a PHP interface to the Blogger API (plant.blogger.com/api) using the useful inc xml-rpc package, but if a response is too big, it flakes out.

Any reports of this happening with eZ?


   RE: Differences between ZEZ and Usefulinc.com Paul Kenneth Egell-Johnsen 15.02.2001 14:52

&gt; Actually, one thing that would make this a winner would be native support for HTTPS (HTTP over SSL/STL). Now that would be cool to have right off the bat.

You need to setup a webserver which support ssl/stl to have this security. You wouldn't have to change existing code.

&gt; Another thing is.. do you guys know of any Perl implementation of the standard with HTTPS support natively?.

As I mentioned above the security is determined by the transport layer. If you use a webserver which has been set up with ssl then the code would work fine without modifications.

http://bitsko.slc.ut.us/~ken/xml-rpc/ is a link to a site with perl server and client for XML-RPC.


     RE: RE: Differences between ZEZ and Usefulinc.com Paul Kenneth Egell-Johnsen 15.02.2001 14:55

&gt; You need to setup a webserver which support ssl/stl to have this security. You wouldn't have to change existing code.

Wrong answer!

That's only true for the server. The client reads directly from the socket and would thus have to have some additions.

My mistake.


Why not RMI and Java? David Escala 05.01.2001 12:12

What are the advantages of using HTTP and XML-RPC over other methods like RMI? I think RMI is faster and much more secure than any implementation of XML-RPC over HTTP.


   RE: Why not RMI and Java? Paul Kenneth Egell-Johnsen 10.01.2001 13:11

&gt; What are the advantages of using HTTP and XML-RPC over other methods like RMI? I think RMI is faster and much more secure than any implementation of XML-RPC over HTTP.

XML-RPC doesn't specifiy any security it only specifices the RPC syntax. You are free to use any common security methods you would usually use for the transport method you are using.

And yeah, the transport method can be any which you care to implement, IIRC.




Forgot your password?

Register a new user

Results

Polls