Programmer Notes

How to resolve XML-RPC Message Format Error

A medical web portal developed using Drupal version 6 had to communicate with a desktop application developed in .NET framework to get a record list of locations. For this, a custom API (web service) was written in XML-RPC protocol. The web service used for the communication was working fine in Drupal 6 version of web application.

Another small web based application under the umbrella of main web portal was developed using Drupal version 8. The same web service was implemented in it but something went wrong.

Problem Identification:

In order to identify the core reason of no data response, the request XML message body of both versions was compared. Many tests were performed too. It was observed that the request was same on both versions, but old version received the data response whereas new version received no data response.

Solution:

The actual problem was with the xmlrpc message body format. The Drupal xmlrpc contributed module was adding carriage returns, spaces and line feeds characters between xml message elements. It was found that:

XMLRPC Server properly accepts XML messages without all the tabs/spaces/carriage returns between the xml elements“.

A solution to remove these characters between the xml elements was developed. After solution implementation, it started working. The web service now received the data response successfully.