This site has been taken over by the staff of www.ASPDeveloper.Net

Please report errors to suggest@aspdeveloper.net

BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
PHP XML
PHP XML RPC Function ServerCreate
PHP XML RPC Function GetType
PHP XML RPC Function EncodeRequest
PHP XML RPC Function Encode
PHP XML RPC Function DecodeRequest
PHP DOMXPath Function registerNamespace
PHP DOMXPath Function query
PHP DOMText Function splitText
PHP DOMText Function isWhitespaceInElementContent
PHP DOMNode Function replaceChild
PHP DOMNode Function lookupPrefix
PHP DOMNode Function lookupNamespaceURI
PHP DOMNode Function isSupported
PHP DOMNode Function isSameNode
PHP DOMNode Function insertBefore
PHP DOMNode Function hasChildNodes
PHP DOMNode Function hasAttributes
PHP DOMNode Function cloneNode
PHP DOMNodelist Function item
PHP DOMNamedNodeMap Function item
 
 

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/24/2008
Times viewed :3520

 

PHP XML RPC Parse Method Descriptions

PHP Version: (PHP 4 >= 4.1.0, PHP 5)

Description

This function decodes the xml into a set of method description.

Usage:

array xmlrpc_parse_method_descriptions ( string xml)

This function decodes the xml into a set of method description. The main objective of this function is to convert the request xml into a list of method description so that you can call appropriate method during server processing.

PHP Code:

This is the server code:

<?php

//This method will be invoked by the server.

function dummyresponse($method, $params) {

switch($params[0]) {

case 'test1':

$reply = 'Your request string contains test1.';

break;

case 'test2':

$reply = 'Your request string contains test2.';

break;

default:

$reply = 'You have requested with no parameters';

}

return $reply;

}

//create a server

$server = xmlrpc_server_create();

//register the 'dummyserver' name as external name and then the 'dummyresponse' name is the actual

//function name.

xmlrpc_server_register_method($server, "dummyserver", "dummyresponse");

//get the request.

$request = $HTTP_RAW_POST_DATA;

//decode the xml into a set of method description

$arr = xmlrpc_parse_method_descriptions($request);

//find the method name

$methodName = $arr['methodName'];

//print the method name

print "Method Name :".$methodName;

//the parameters here are 'server, xml-string and user data'.

$response = xmlrpc_server_call_method($server, $request, null);

//print the response

print $response;

//destroy the server

xmlrpc_server_destroy($server);

?>

The client PHP code is

<?php

functiondo_call($host, $port, $request) {

$fp = fsockopen($host, $port, $errno, $errstr);

$query = "POST /default/php/xmlrpc_parse_method_descriptionsserve.php HTTP/1.0\nUser_Agent: This is a Dummy Client\nHost: ".$host."\nContent-Type: text/xml\nContent-Length: ".strlen($request)."\n\n".$request."\n";

echo '<PRE>';

echo $query;

echo '</PRE>';

if (!fputs($fp, $query, strlen($query))) {

$errstr = "Write error";

return 0;

}

$contents = '';

while (!feof($fp)) {

$contents .=fgets($fp);

}

fclose($fp);

return $contents;

}

$host = 'localhost';

$port = 80;

$request = xmlrpc_encode_request('dummyserver', 'test1');

$response = do_call($host, $port, $request);

//print the response

echo $response;

?>

The method name is as echoed out in server:

Method Name :dummyserver


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

Software Specialist, Linux - Finlan
Linux Core Technical Project Manage
Graphics designer at Tanzania. Expe
Integration Specialist Needed - Wor
Virtualization Server Infrastructur

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






    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