By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,639 Members | 3,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,639 IT Pros & Developers. It's quick & easy.

xml-rpc webserver

P: n/a
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) {props+=prop+'='+obj[prop]+'\n';}
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";,url,true);
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');
Jan 23 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.