xml-rpc webserver

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Been banging my head on this all day, so here's the stoopid question:

        Do we *really need* the xml-rpc extension to create a xmlrpc  
webservice ?  

I'm getting the impression that we're supposed to generate the XML by hand.  
That's why PHP 5.1.2 has DOM methods as well as an xmlwriter class.

And invoking the webserver "function/class" can be done by general PHP code  
as well, no need for *registering the method with the server* ?

Many webauthors urge us to precede any xml output with : header('Content-
Type: text/xml');

So if we have to do all that ourselves, what work does the xml-rpc  
extension actually do ?  

Below is my first webservice effort, using POST.  

The js-client sends "Kilroy", and the webservice appends ' was here'.
I'm receiving an XML object all right, but it appears empty.

Any help appreciated...


//save this as server.php
function stick($method, $param) {      
   return ("$param was here !");    
$server = xmlrpc_server_create();
xmlrpc_server_register_method($server, "glue", "stick");
$xmlresponse= xmlrpc_server_call_method($server, $rawpost, '');
header('Content-Type: text/xml');
echo $xmlresponse;  

//save this as client.html (most of the code courtesy of PPK)
var XMLHttpFactories = [
    function () {return new XMLHttpRequest()},
    function () {return new ActiveXObject("Msxml2.XMLHTTP")},
    function () {return new ActiveXObject("Msxml3.XMLHTTP")},
    function () {return new ActiveXObject("Microsoft.XMLHTTP")},

function dspobjprop(obj) {
    var props="";
    for (var prop in obj)
    alert (props);  
function createXMLHTTPObject() {
    var xmlhttp = false;
    for (var i=0;i<XMLHttpFactories.length;i++)
        try {
            xmlhttp = XMLHttpFactories[i]();
        catch (e) {
    return xmlhttp;

function sendRequest(url,callback, postData) {
    var req = createXMLHTTPObject();
    if (!req) return;
    var method = (postData) ? "POST" : "GET";
    if (postData)                
        req.onreadystatechange = function () {
            if (req.readyState != 4) return;
            if (req.status != 200 && req.status != 304) {            
                alert('HTTP error ' + req.status);
    if (req.readyState == 4) return;    

function handleResponse(req){         
     var returnXML=req.responseXML;    

var data="Kilroy";
sendRequest('server.php', handleResponse, 'POST');


Site Timeline