Tuesday, January 27, 2009

User defined xml reponse in drupal 6 webservices

XMLRPC server gives xml reponse in following way.

<methodResponse>
  <fault>
   <value>
    <struct>
     <member>
      <name></name>
      <value><int></int></value>
     </member>
     <member>
      <name></name>
      <value><string></string></value>
     </member>
    </struct>
   </value>
  </fault>
</methodResponse>



But If you want to use your own xml format for response, then edit includes/xmlrpcs.inc

Comment following code at line number 77
$xml = xmlrpc_value_get_xml($r);

and while returning the value, return response in xml format. For example

function myservices_test($name){
  $response = "<root>
    <name>".$name."</name>
</root>";


  return $response;
}

No comments: