Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8569517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:21:13+00:00 2026-06-11T18:21:13+00:00

I am working with webservices using xmlrpc-epi for a PHP/MySQL based website, I am

  • 0

I am working with webservices using xmlrpc-epi for a PHP/MySQL based website, I am getting xmlrpc client respaonse like below:

opening socket to host: comingsoon.com, port: 80, uri: /CM_server.php
sending http request:
POST /CM_server.php HTTP/1.0
User-Agent: xmlrpc-epi-php/0.2 (PHP) 
Host: fn24dev.com:80 Content-Type: text/xml 
Content-Length: 117 
<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall> 
<methodName>listVideos</methodName> 
<params/> 
</methodCall>
receiving response...
got response:
<?xml version="1.0" encoding="iso-8859-1"?> 
<methodResponse> 
<params>
 <param>
  <value>
   <array>
    <data>
     <value>
      <struct>
       <member>
        <name>0</name>
         <value>
          <string>63</string>
         </value>
       </member>
       <member>
        <name>indexer</name>
         <value>
          <string>63</string>
         </value>
       </member>
       <member>
        <name>1</name>
        <value>
         <string>02_CHIMPPANTS_24-03-2012_04-43-06</string>
        </value>
       </member>
       <member>
        <name>video_id</name>
        <value>
         <string>02_CHIMPPANTS_24-03-2012_04-43-06</string>
        </value>
       </member>
       <member>
        <name>2</name>
        <value>
        <string>mp4</string>
        </value> </member>
      <member>
        <name>type</name>
        <value>
         <string>mp4</string>
        </value>
      </member>
     </struct>
   </value> 
  </data> 
  </array>
</value>
</param>
</params>
</methodResponse>

In this, I am getting both mysql table fieldnames and field values as xml text contents. But I want to get response like mysql fieldnames as element and field values as text content. like below,

<member>
       <indexer>63</indexer>
</member>

<member>
      <video_id>02_CHIMPPANTS_24-03-2012_04-43-06</video_id>
</member>
<member>
  <type>mp4</type>
</member>

I’ve added PHP code & mysql table and data for clarifications.

Table_name: videos
    indexer     video_id                           type
    --------       ----------------------------------  -----
    63          02_CHIMPPANTS_24-03-2012_04-43-06      mp4
    54          02_Friday_23-03-2012_05-11-18          mp4

CM_server.php

<?php
function Connect(){
$connect = mysql_connect("localhost","root","");
$db = mysql_select_db("database") or die("Database is not valid");
}

//Get the Videos
function getVideos(){
//connect database
Connect();
$videoquery = mysql_query("select * from videos");
    if(mysql_num_rows($videoquery) == "0"){
        $returnquery = "0";
    } else {
        while($getquery = mysql_fetch_array($videoquery)){
            $returnquery[] = $getquery;
        }
    }
    return $returnquery;
}
//server creating and check a list a method
$request = $HTTP_RAW_POST_DATA;
if (!$request) $request_xml = $HTTP_POST_VARS['xml'];
$server = xmlrpc_server_create( );
if (!$server) die("Couldn't create server");
xmlrpc_server_register_method($server, 'listVideos', 'getVideos');
$options = array('output_type' => 'xml', 'version' => 'auto');
echo xmlrpc_server_call_method($server, $request, null, $options);
xmlrpc_server_destroy($server);
?>

client.php

<?php
include("utils.php");
$options = array('output_type' => 'xml', 'version' => 'xmlrpc');
$result1 = xu_rpc_http_concise(array(method => 'listVideos',host  => 'comingsoon.com',uri=> '/CM_server.php',options => $options,debug => 1));
?>

utils.php

<?php
xu_load_extension();
// a function to ensure the xmlrpc extension is loaded.
// xmlrpc_epi_dir = directory where libxmlrpc.so.0 is located
// xmlrpc_php_dir = directory where xmlrpc-epi-php.so is located
function xu_load_extension($xmlrpc_php_dir="") {
   if(!extension_loaded('xmlrpc')) {
      $bSuccess = true;
      putenv("LD_LIBRARY_PATH=/usr/lib/php4/apache/xmlrpc/");
      if ($xmlrpc_php_dir) {
         $xmlrpc_php_dir .= '/';
      }
      if (!extension_loaded("xmlrpc")) {
         $bSuccess = dl($xmlrpc_php_dir . "xmlrpc-epi-php.so");
      }
   }
   return $bSuccess;
}

/* generic function to call an http server with post method */
function xu_query_http_post($request, $host, $uri, $port, $debug, 
                            $timeout, $user, $pass, $secure=false) {
   $response_buf = "";
   if ($host && $uri && $port) {
      $content_len = strlen($request);

      $fsockopen = $secure ? "fsockopen_ssl" : "fsockopen";

      dbg1("opening socket to host: $host, port: $port, uri: $uri", $debug);
      $query_fd = $fsockopen($host, $port, $errno, $errstr, 10);

      if ($query_fd) {

         $auth = "";
         if ($user) {
            $auth = "Authorization: Basic " .
                    base64_encode($user . ":" . $pass) . "\r\n";
         }

         $http_request = 
         "POST $uri HTTP/1.0\r\n" .
         "User-Agent: xmlrpc-epi-php/0.2 (PHP)\r\n" .
         "Host: $host:$port\r\n" .
         $auth .
         "Content-Type: text/xml\r\n" .
         "Content-Length: $content_len\r\n" . 
         "\r\n" .
         $request;

         dbg1("sending http request:</h3> <xmp>\n$http_request\n</xmp>", $debug);

         fputs($query_fd, $http_request, strlen($http_request));

         dbg1("receiving response...", $debug);

         $header_parsed = false;

         $line = fgets($query_fd, 4096);
         while ($line) {
            if (!$header_parsed) {
               if ($line === "\r\n" || $line === "\n") {
                  $header_parsed = 1;
               }
               dbg2("got header - $line", $debug);
            }
            else {
               $response_buf .= $line;
            }
            $line = fgets($query_fd, 4096);
         }

         fclose($query_fd);
      }
      else {
         dbg1("socket open failed", $debug);
      }
   }
   else {
      dbg1("missing param(s)", $debug);
   }

   dbg1("got response:</h3>. <xmp>\n$response_buf\n</xmp>\n", $debug);

   return $response_buf;
}

function xu_fault_code($code, $string) {
   return array('faultCode' => $code,
                'faultString' => $string);
}


function find_and_decode_xml($buf, $debug) {
   if (strlen($buf)) {
      $xml_begin = substr($buf, strpos($buf, "<?xml"));
      if (strlen($xml_begin)) {

         $retval = xmlrpc_decode($xml_begin);
      }
      else {
         dbg1("xml start token not found", $debug);
      }
   }
   else {
      dbg1("no data", $debug);
   }
   return $retval;
}

function xu_rpc_http_concise($params) {
   $host = $uri = $port = $method = $args = $debug = null;
   $timeout = $user = $pass = $secure = $debug = null;

    extract($params);

    // default values
    if(!$port) {
        $port = 80;
    }
    if(!$uri) {
        $uri = '/';
    }
    if(!$output) {
        $output = array(version => 'xmlrpc');
    }

   $response_buf = "";
   if ($host && $uri && $port) {
      $request_xml = xmlrpc_encode_request($method, $args, $output);
      $response_buf = xu_query_http_post($request_xml, $host, $uri, $port, $debug,
                                         $timeout, $user, $pass, $secure);

      $retval = find_and_decode_xml($response_buf, $debug);
   }
   return $retval;
}

/* call an xmlrpc method on a remote http server. legacy support. */
function xu_rpc_http($method, $args, $host, $uri="/", $port=80, $debug=false, 
                     $timeout=0, $user=false, $pass=false, $secure=false) {
    return xu_rpc_http_concise(
        array(
            method  => $method,
            args    => $args,
            host    => $host,
            uri     => $uri,
            port    => $port,
            debug   => $debug,
            timeout => $timeout,
            user    => $user,
            pass    => $pass,
            secure  => $secure
        ));
}



function xu_is_fault($arg) {
   // xmlrpc extension finally supports this.
   return is_array($arg) ? xmlrpc_is_fault($arg) : false;
}

/* sets some http headers and prints xml */
function xu_server_send_http_response($xml) {
    header("Content-type: text/xml");
    header("Content-length: " . strlen($xml) );
    echo $xml;
}


function dbg($msg) {
   echo "<h3>$msg</h3>"; flush();
}
function dbg1($msg, $debug_level) {
   if ($debug_level >= 1) {
      dbg($msg);
   }
}
function dbg2($msg, $debug_level) {
   if ($debug_level >= 2) {
      dbg($msg);
   }
}


?>

If anyone knows xmlrpc to get this solution please guide me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:21:15+00:00Added an answer on June 11, 2026 at 6:21 pm

    The structure you are asking for would not be XML-RPC, so you will not be able to achieve it using PHP’s XML-RPC extension. The XML-RPC Specification defines a precise structure for responses, including the available types.

    The kind of XML service you have in mind just needs an XML parsing library (e.g. SimpleXML), some XML creation functions (which could be a recursive function turning a PHP array into an XML-formatted string) and a small amount of “dispatching code” to support different methods on one URL:

    $request_xml = file_get_contents('php://input');
    $request_sx = simplexml_load_string($request_xml);
    switch ( (string)$request_sx->Method )
    {
        case 'listVideos':
            $data = getVideos( (string)$request_sx->Params->SearchTerm );
            $response_xml = generate_xml($data);
        break;
    }
    
    header('Content-Type: text/xml');
    echo $response_xml;
    exit;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm filling some labels using jQuery AJAX and it's working properly (i'm getting the
I am working on webservices with spring DI. I am using the Eclipse IDE
I am working on Java web service using TOMCAT server over secured connection(SSL). Client
i'm working with SOA using WebServices. So i need to send a XML request
I am new to Java web-services and am working on one currently, using Apache
I have been working with WebServices for sometime. I dealt with many services where
My organization is working on building RESTful webservices on JBoss appserver. The QA team
I am working on a Silverlight client and associated ASP.NET web services (not WCF),
I'm working on an Android app that connects to .NET webservices. I use the
I've an application built using Spring 3, Spring webservices 2.0 , JDK 1.6 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.